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.

Reply
nidhs909
Frequent Visitor

RANKX for multiple columns including date column with slicer on date

Hello All, 

 

nidhs909_0-1720443739738.png

I have a EmpID and Date Data as above. what I am trying to achieve is the rank considering both the columns. It should be as a measure as i need a date as slicer. 

 

Thanks in advance. 

 

1 ACCEPTED SOLUTION

Thanks alot, worked like a charm!

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi, @rajendraongole1 

Based on your information, I create a table:

vyohuamsft_0-1720502515738.png

 

Then create a new measure and use the following dax:

Rank = ROWNUMBER(ALLSELECTED('Table'[EmpID],'Table'[Custom Date]),ORDERBY('Table'[EmpID],ASC,'Table'[Custom Date],DESC))

Here is my preview:

vyohuamsft_1-1720502615998.png

Even if the date is changed, its ranking changes dynamically:

vyohuamsft_2-1720502683669.png

 

How to Get Your Question Answered Quickly 

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This is what i would like to achieve. 

 

EmpIDDateRank
53331st Jan, 20241
53332nd Jan, 20242
53332nd Jan, 20242
53333rd Jan, 20243
50751st Jan, 20241
50752nd Jan, 20242
50753rd Jan, 20243
50753rd Jan, 20243
Anonymous
Not applicable

Hi, @nidhs909 

You can use the following DAX expression:

RankMeasure = 
VAR _currentID = MAX('Table'[EmpID])
RETURN
CALCULATE(
    RANKX(
        FILTER(ALLSELECTED('Table'),'Table'[EmpID]=_currentID),
        CALCULATE(MAX('Table'[Custom Date])),
        ,
        ASC,
        Dense
    ),
    ALLEXCEPT('Table', 'Table'[Custom Date])
)

Here is my preview:

vyohuamsft_0-1720512092191.png

However, the Table visual will automatically aggregate the same value, for example, the same date and the same ID will be aggregated into the same row of data, so I created an Index in PowerQuery in advance to show the order when duplicated.

 

How to Get Your Question Answered Quickly 

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks alot, worked like a charm!

rajendraongole1
Super User
Super User

Hi @nidhs909 -If you don't already have a date table, you can create one as below:

DateTable = CALENDAR(MIN(EmpData[Date]), MAX(EmpData[Date]))

establish a relationship between date table and employee table and use the below measure.

Please create the below measure

 

EmpRank =
VAR SelectedDate = SELECTEDVALUE(DateTable[Date])
RETURN
RANKX(
FILTER(
EmpData,
EmpData[Date] <= SelectedDate
),
EmpData[EmpID],
,
ASC,
Dense
)

 

 

Hope it works

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Unfortunately, it gives this error. 

 

A single value for column 'EmpID' in table 'XXX' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.