cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sharifahy
Helper II
Helper II

RANKX by Year and Month

Hi,

 

I want to RANK my data according to their respective year and month. Every date that falls in the same year and month, must be in the same group. There are no other criterias needed. Just to rank it and I'm trying to do the syntax below but still doesn't work

 

RANKX(FILTER(Product,EARLIER([ReceiveDate].[Year])=YEAR([ReceiveDate])&&EARLIER([ReceiveDate].[Month])=[ReceiveDate].[Month]),[Id],,DESC)

 

1 ACCEPTED SOLUTION
amitchandak
Super User IV
Super User IV

@sharifahy , if want to have the same rank for the dates in the month then you need to have ranked on the month year.

Better create month year and rank on it

 

example

Month Year = FORMAT([Date],"mmm-yyyy")
Month Rank = RANKX(ALL('Date'),'Date'[Month Year Sort],,DESC,Dense)



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

View solution in original post

2 REPLIES 2
daxer
Solution Sage
Solution Sage

@sharifahy 

 

Please refrain from using the auto-generated date hierarchies which are meant to be used only in the simplest of models for quick prototyping and NOTHING ELSE. Create your own calendar with all attributes needed. Connect all fact tables to this calendar dimension table instead of having hierarchies in each of the date columns in your fact tables. This is Best Practice which reduces the model bloat and lets you do calculations in a simple and predictable way. As mentioned by @amitchandak, you should create a YearMonth column of the type YYYYMM (integer) and then rank on it.

amitchandak
Super User IV
Super User IV

@sharifahy , if want to have the same rank for the dates in the month then you need to have ranked on the month year.

Better create month year and rank on it

 

example

Month Year = FORMAT([Date],"mmm-yyyy")
Month Rank = RANKX(ALL('Date'),'Date'[Month Year Sort],,DESC,Dense)



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

View solution in original post

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

April Update

Check it Out!

Click here to read more about the April 2021 Updates!

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

Top Solution Authors