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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
vendersonalias0
Frequent Visitor

How to get date filters working in RANKX measure?

 

car sales.PNG

I have a mock table with 1000 rows of car sales data, shown above. There are only a handful of different car combinations and I am interested in seeing what the average selling price is across a time period, which is simply a measure of Total Revenue / Number of Sales

 

 

rank measure.PNG

The above table is looking at the car sales breakdown minus the date. It is sorted by

Avg Sale Price = DIVIDE(SUM('Car Sales Mock'[Total Revenue]),SUM('Car Sales Mock'[Number of Sales]))
which is working well. I was also able to create a measure Avg Sale Price Rank to rank the highest priced cars on average, which works even when slicing by color, or car make.
 
Avg Sale Price Rank = RANKX(ALLSELECTED('Car Sales Mock'),CALCULATE([Avg Sale Price],ALLEXCEPT('Car Sales Mock','Car Sales Mock'[Car Make],'Car Sales Mock'[Car Year],'Car Sales Mock'[Color])),,DESC,Dense)
 
However, whenever I slice by a date, such as a month or quarter, the ranking breaks. Hence the avg sales price rank 2 and 3 measures which were my attempt at getting a working measure.
 
 
link for pbix file attached!
 

 

2 REPLIES 2
amitchandak
Super User
Super User

@vendersonalias0 , Try once like this

RANKX(ALLSELECTED('Car Sales Mock','Car Sales Mock'[Car Make],'Car Sales Mock'[Car Year],'Car Sales Mock'[Color]),CALCULATE([Avg Sale Price]),,DESC,Dense)

 

I have not checked the file yet

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

Hi, thanks that seems to be very close, it is now working wiht the date slicer but it is skipping some numbers if the car didn't have any sales that monthexample rankx.PNG

Thanks, it seems liek were a step closer but there are still some weird variations such as two rank 7, and osmetimes they will skip a rank. 

 

I did have to adjust your measure to remove the table reference 'car sales mock' since it said that multiple argumetns are not allowed in the allselected function when the first argument is a table refrence.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

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

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.

Top Solution Authors
Top Kudoed Authors