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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ToddChitt
Super User
Super User

RANKX for YTD

Hello all:

This seems it should be fairly straight forward bu still eludes me.

I am trying to get a RANKX of Customers based on YTD Sales, such that the Ranking will respect the Date slicer on the page.

The model is quite simple: 3 tables, appropriately related

* Sales (fact)

* Customer (dim)

* Date (dim)

 

I have a [Sales Sum] and [Sales YTD] measures defined in the fact table

Sales Sum = sum('Sales'[ExtSales])

* Sales YTD = TOTALYTD([Sales Sum],'Dates Table'[Date])

 

I think this needs to be a MEASURE, not a calculated column.

I have tried this:

RANKX YTD =
     RANKX (
          ALL('Customers'[customer_name]),
                 CALCULATE(
                 [Sales YTD]
              )
         )
 
But a simple table visual with Customer Nam shows 1 for every [RANKX YTD] (There is a Date slicer on the page to give the calculations some date context.
 
Any help would be appreciated. Thanks in advance.



Did I answer your question? If so, mark my post as a solution. Also consider helping someone else in the forums!

Proud to be a Super User!





4 REPLIES 4
VijayP
Super User
Super User

@ToddChitt 

Just CALCULATE Function inside RANK Measure and see the result.




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


@VijayP As in:

RANKX YTD 2 =  RANKX (   'Customers', CALCULATE(  [Sales YTD]  )
?
No, I still get 1's.



Did I answer your question? If so, mark my post as a solution. Also consider helping someone else in the forums!

Proud to be a Super User!





amitchandak
Super User
Super User

@ToddChitt , are you using anything other than 'Customers'[customer_name] in the visual that is not summarized. If so 'Customers'[customer_name] will rank inside that.

@amitchandak No. My table visual contains only Customer_Name, but the data table is related to Sales on Customer_ID. 

One issue I am fighting with the data owner is that Customer_Name is not unique in the Customer table, but ID is. Not sure if that matters.

Thanks




Did I answer your question? If so, mark my post as a solution. Also consider helping someone else in the forums!

Proud to be a Super User!





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.