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 usage with categorical sum

I need a measure to calculate the rank of customer's sales. The picture bellow describes the table I have:

CustomerSalesDateRank
A1001 Jan 2018??
A2005 Jan 2018??
B2005 Jan 2018??
B2005 Feb 2018??
A2005 Mar 2018??
C3005 Apr 2018??
C10001 May 2018??

 

 

 I have a date slicer in the report and I would like the rank to be depended of the selected date range. For example, if the range is from 01 Janurary - 01 May, this should be the result:

CustomerSalesDateRank
A1001 Jan 20182
A2005 Jan 20182
B2005 Jan 20183
B2005 Feb 20183
A2005 Mar 20182
C3005 Apr 20181
C10001 May 20181

 

 

However if the range selected is 01 Janurary - 05 April, the rank would become: 

CustomerSalesDateRank
A1001 Jan 20181
A2005 Jan 20181
B2005 Jan 20182
B2005 Feb 20182
A2005 Mar 20181
C3005 Apr 20183
C10001 May 20183

Because only the 100$ sales of customer C would not be considered in the rank formula.

 

I believe I should use the rankx formula but I have no idea how to include the sum of each customer in the expression. Also I need to solution to be a measure as it needs to be calculated on the go depending on the date range selection

please help. Thanks you

1 ACCEPTED SOLUTION

Hi @Anonymous,

 

Try this measure, please. If you'd like to show all the "C", you need a date table. Please refer to the snapshot.

Measure =
CALCULATE (
    RANKX ( ALL ( Table1[Customer] ), CALCULATE ( SUM ( Table1[Sales] ) ) ),
    ALLSELECTED ( Table1[Date] )
)

Rankx-usage-with-categorical-sum

 

Best Regards,
Dale

Community Support Team _ Dale
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

4 REPLIES 4
AlB
Super User
Super User

Hi @Anonymous

Can you post the data in text format so that it can be readily copied? Or share the pbix?

Anonymous
Not applicable

Appologies! I'm quite new so I don't know the rules around here. The post have been updated. Thanks in advance! 

Hi @Anonymous,

 

Try this measure, please. If you'd like to show all the "C", you need a date table. Please refer to the snapshot.

Measure =
CALCULATE (
    RANKX ( ALL ( Table1[Customer] ), CALCULATE ( SUM ( Table1[Sales] ) ) ),
    ALLSELECTED ( Table1[Date] )
)

Rankx-usage-with-categorical-sum

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Exacty the thing I want, thank you very much!

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.