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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
JJ1214
Regular Visitor

Rankx filtering for past year

Hi everyone I want to use Rankx to calculate a ranking for my data over the past year ignoring any entries in the days before. I tried the following: RANKX(DATESINPERIOD(Table[Date],MAX(Table[Date]),-1,YEAR),CALCULATE(SUM(Table[Amount])),,ASC,Dense)

 

However, the results are not correct. Can anyone advise please?

2 REPLIES 2
amitchandak
Super User
Super User

@JJ1214 ,You want Rank Last year data , what is group by ?

 

first create a measure like

Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))

 

or

Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))

or
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),SAMEPERIODLASTYEAR('Date'[Date]))

 

then try rank

RANKX(allselected(Table),[Year behind Sales],,ASC,Dense)

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you very much for your response. I think I did not state my question correctly. I would like to have the daily sums per Customer group but only for the past year such that the ranking for the specific customer group ignores all values in the year before. Is that possible somehow? If I introduce a relative date filter in the visual, the ranking shows incorrect values.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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