Skip to main content
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

View discussion in a popup

Replying to:
NilR
Post Patron

DAX Issue- Rankx by multiple Categories

I have 4 Categories (GP, ID, Age, Date). I would would like to create calculated column and group by GP, ID, and Age and Rank/ count by Date to see how many months each member has in past 24 month.

My Code works until I have members who cancelled their membership for a few months and then resumed after. I need to restart from the first month after skip. for example :

GROUPIDAGEDATECurrent RankDesired RANK
122035-44202206126
122035-44202205125
122035-44202204124
122035-44202203123
122035-44202202122
122035-44202201121
122035-442020122424
122035-442020112323
122035-442020102222
122035-442020092121
122035-442020082020
122035-442020071919
122035-442020061818
122035-442020051717
122035-442020041616
โ€ฆโ€ฆโ€ฆโ€ฆโ€ฆโ€ฆ
122035-4420190111

This is what I have tried but doesn't work for dates skipping.

RKING= 
RANKX (
CALCULATETABLE (
               VALUES ('tbl'[Date] ),
               ALLEXCEPT ( 'tblW', 'tbl'[GP], 'tbl'[ID] ),
                         'tbl'[AGE] = 'tbl'[AGE],
                         'tbl'[date] >= start_date && 'tbl'[date] <= end_date // date slicer
                ),
[Date] ,
,ASC
)