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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

RANKX by Date and Multiple Categories (PBIX inside)

Hi!

 

I want to be able to RANKX by Date and 2 more columns.

So far with 1 column it works, for that I use the following measure:

 

 

RANK Room_Date = 
RANKX(
    FILTER('FACT Rooms', 'FACT Rooms'[RoomID] = EARLIER('FACT Rooms'[RoomID])),
    [Date],,ASC,Dense)

 

 

However I want to adapt this to a measure that also takes into account for the `Status`, as shown in the Dataset below, the last column 'RANK Room_Date_Status'. As you can see it starts from 1 again when it shifts from Empty to Full or the other way around.

 

RoomIDStatusFromDateToDateDaysDateDiff (ToDate - Date)DatumRANK Room_DateRANK Room_Date_Status
1Empty1/1/20201/10/20201071/3/202033
1Empty1/1/20201/10/20201061/4/202044
1Empty1/1/20201/10/20201051/5/202055
1Empty1/1/20201/10/20201041/6/202066
1Empty1/1/20201/10/20201031/7/202077
2Full1/1/20201/4/2020411/3/202033
2Full1/1/20201/4/2020401/4/202044
2Empty1/5/20201/6/2020211/5/202051
2Empty1/5/20201/6/2020201/6/202062
2Full1/7/20201/10/2020431/7/202071
3Full1/1/20201/5/2020521/3/202033
3Full1/1/20201/5/2020511/4/202044
3Full1/1/20201/5/2020501/5/202055

 

TestFile.pbix 

 

Any suggestions how to do this?

 

Kind regards,

Igor

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks for the quick response, those links are very valuable and made me easily understand what I needed to adapt.

 

I made the following calculated column which actually does the trick. I could of course simply add more statements in my FILTER statement.

 

RANK Room_Date_Status = 
RANKX(
    FILTER(
        'FACT Rooms', 
        'FACT Rooms'[RoomID]    = EARLIER('FACT Rooms'[RoomID]) && 
        'FACT Rooms'[Status]    = EARLIER('FACT Rooms'[Status]) && 
        'FACT Rooms'[FromDate]  = EARLIER('FACT Rooms'[FromDate])
    ),
    [Date],,ASC,Dense)

 

The MAX date is simply used so I can show the daycount in a Matrix visualization. I doesn't allow for a calculated column as value, so I simply put a MAX or MIN around it. I don't use that one anywhere else but the visualization.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thanks for the quick response, those links are very valuable and made me easily understand what I needed to adapt.

 

I made the following calculated column which actually does the trick. I could of course simply add more statements in my FILTER statement.

 

RANK Room_Date_Status = 
RANKX(
    FILTER(
        'FACT Rooms', 
        'FACT Rooms'[RoomID]    = EARLIER('FACT Rooms'[RoomID]) && 
        'FACT Rooms'[Status]    = EARLIER('FACT Rooms'[Status]) && 
        'FACT Rooms'[FromDate]  = EARLIER('FACT Rooms'[FromDate])
    ),
    [Date],,ASC,Dense)

 

The MAX date is simply used so I can show the daycount in a Matrix visualization. I doesn't allow for a calculated column as value, so I simply put a MAX or MIN around it. I don't use that one anywhere else but the visualization.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.