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
Jmash
New Member

Power BI Rank Based on Day on Day Change.

Hi All,

How to frame a logic for ranking dataset based on a category and its DoD % Chnage for the below example. Table below shows DoD% increase Change Column. I want to rank them from 1 to 100 based on daily movement by country in Power BI Dax.

DateCountryBalance USDDoD % ChangeRank Based on DoD Change
3/01/2020A5681%1
7/01/2020A25664%2
4/01/2020A8755%3
2/01/2020A3155%4
6/01/2020A15647%5
8/01/2020A36643%6
4/01/2020B5043%7
3/01/2020B3540%8
5/01/2020B7040%9
6/01/2020B9536%10
7/01/2020B12532%11
11/01/2020A65629%12
8/01/2020B16028%13
9/01/2020A45825%14
2/01/2020B2525%15
9/01/2020B20025%16
10/01/2020B24523%17
5/01/2020A10622%18
11/01/2020B29520%19
12/01/2020A78420%20
12/01/2020B35019%21
13/01/2020B41017%22
14/01/2020B47516%23
10/01/2020A51011%24
13/01/2020A8569%25
14/01/2020A9258%26
1/01/2020A20 27
1/01/2020B20 27
1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @Jmash ,

 

If you want to sort [DoD % Change] by grouping by [Date] and [Country], you can try the following dax:

Measure =
RANKX(
    FILTER(ALLSELECTED('Table'),   'Table'[Date]=MAX('Table'[Date])&&'Table'[Country]=MAX('Table'[Country])),CALCULATE(SUM('Table'[DoD % Change])),, DESC)

If you want to implement [Rank Based on DoD Change] to do a sort on all, you can try the following dax:

Measure 2 =
RANKX(
    ALLSELECTED('Table'),
    CALCULATE(SUM('Table'[DoD % Change])),,DESC)

 

Best Regards,

Liu Yang

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

View solution in original post

2 REPLIES 2
v-yangliu-msft
Community Support
Community Support

Hi  @Jmash ,

 

If you want to sort [DoD % Change] by grouping by [Date] and [Country], you can try the following dax:

Measure =
RANKX(
    FILTER(ALLSELECTED('Table'),   'Table'[Date]=MAX('Table'[Date])&&'Table'[Country]=MAX('Table'[Country])),CALCULATE(SUM('Table'[DoD % Change])),, DESC)

If you want to implement [Rank Based on DoD Change] to do a sort on all, you can try the following dax:

Measure 2 =
RANKX(
    ALLSELECTED('Table'),
    CALCULATE(SUM('Table'[DoD % Change])),,DESC)

 

Best Regards,

Liu Yang

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

amitchandak
Super User
Super User

@Jmash , You can have date table and create DOD using Time Intelligence

 

example

 

This Day = CALCULATE(SUM(Table[Value]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])))


Last Day = CALCULATE(SUM(Table[Value]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])-1))


Last Day = CALCULATE(SUM(Table[Value]), previousday('Date'[Date]))

 

DOD = divide([This Day]- [Last Day], [Last Day])

 

and you can create rank post that

 

Rankx(allselected(Table[Date]), [DOD])

 

Day Intelligence - Last day, last non continous day
https://medium.com/@amitchandak.1978/power-bi-day-intelligence-questions-time-intelligence-5-5-5c324...

 

Measure Rank: https://www.youtube.com/watch?v=DZb_6j6WuZ0&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=40
https://www.youtube.com/watch?v=cN8AO3_vmlY&t=25627s

 

Power BI - New DAX Function: RANK - How It Differs from RANKX: https://youtu.be/TjGkF44VtDo

 

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.