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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.