cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jawilson808
Helper I
Helper I

Ranking by Business date and day of Week

Hi All!

 

Looking for some assistance. What seems relatively easy is causing me some difficulty. I am looking to rank my sales by different date slicers including the day of week. I have two different tables, one containing my calculated measures derived from other tables and another table containing my dates. When adding in my sales measure and day of week dimension into a matrix, the following formula seems to work somewhat ok if my date slicer is set to week. I say somewhat because it doesn't seem to rank properly, nor does it rank 1 - 7 with one being the highest day.

Sales Rank = RANKX(all([BusinessDate]),[CY Sales],,DESC,Dense)
jawilson808_0-1641588354821.png

 

When I set my page level slicer to This month it returns all ones. However, if I add dates to the table it then returns some values. But again the ranking doesn't seem to be accurate.
jawilson808_1-1641588468604.png

 

What am I doing wrong? Any assistance would be greatly appreciated.

 
3 REPLIES 3
amitchandak
Super User
Super User

@jawilson808 , A measure rank repeat for any other column used then the one used in rank.

Sales Rank = RANKX(all([BusinessDate]),[CY Sales],,DESC,Dense)

 

It means when you use day week, rank will done for Business date inside Day of week

 

Try like

Sales Rank = RANKX(all([BusinessDate], [Day of week]),[CY Sales],,DESC,Dense)



Power BI Features || Datamarts: https://youtu.be/8tskWsJTEpg || Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Time Intelligence Decoded : https://youtu.be/aU2aKbnHuWs&t=145s
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Dashboard of My Blogs !! Connect on Linkedin !! Subscribe to my youtube Channel !!
Want To Learn Power BI | Beginners !! Advance Concepts !! Power BI For Tableau User !!

Hi @amitchandak,

Thank you for getting back to me. The formula you provided works similar to the one that I was able to come up with. However, if the slicer is filtered for the month and the table only contains day of week, it returns all 1's, however, if its filter for a week, it does return a rank.

If the table contains both date and day of week it does return a rank. In an ideal solution, I would like to be able to rank the entire month, year, week and etc as an aggregate to day of week and not have to include date depending on how the user filters the report. 

 

See screenshots below of what returned with the update to the formula. 

 

Filtered by month

jawilson808_2-1641835545565.png

 

Filtered by week

jawilson808_1-1641835509082.png

 

jawilson808
Helper I
Helper I

I've have almost figured it out. I updated the formula to 


SalesDOW Rank =
RANKX(ALLSELECTED(BusinessDate),
Calculate([CY Sales]),,DESC)

When doing so, it properly ranks by business date and day of week. However, if I filter my results for month or year, my table in which contains only the measures I want by day of week, it is not aggregating all days of week together. 
 
This is good
jawilson808_0-1641592726283.png

 

This is not good when filtering by month in the top matrix. The bottom matrix however is ok. 

jawilson808_1-1641592781336.png

 


 

Helpful resources

Announcements
August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power BI Dev Camp Session 24 without aka link and time 768x460.jpg

Ted's Dev Camp - July 28, 2022

Watch Session 24 of Ted's Dev Camp along with past sessions!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors