Forum Discussion
DAX: Ranking or Indexing Dates
- 10 years ago
In this scenario, we can rank Invoice Month (from earliest month) within each Signup Month group, and use the rank number as the column group in Matrix. Please refer to following steps:
- Create a measure for the number of customers.
TotalCustomer = CALCULATE(COUNTROWS('Raw Cohort data')) - Since we will rank the month values, we need to convert the Invoice date into number.
Inv_Year&Month = VALUE ( YEAR ( 'Raw Cohort data'[Invoice_Month] ) & "0" & MONTH ( 'Raw Cohort data'[Invoice_Month] ) ) - Create a column for the rank by Inv_Year&Month within Signup month. You can see the rank in below table chart.
RankInvoiceYear&Month = RANKX ( FILTER ( 'Raw Cohort data', EARLIER ( 'Raw Cohort data'[Signup Month] ) = 'Raw Cohort data'[Signup Month] ), 'Raw Cohort data'[Inv_Year&Month], , ASC, DENSE ) - Drag below data fields into the Matrix chart. Since you already know the DAX for the % view, you can replace “RankInvoiceYear&Month” with the % view DAX and then you can get another % view Matrix.
- Create a measure for the number of customers.
Thanks Sean, yes the hook is that the time period is greater than 12 months, and grows through time. Any suggestions ?
Cheers
Steve
In this scenario, we can rank Invoice Month (from earliest month) within each Signup Month group, and use the rank number as the column group in Matrix. Please refer to following steps:
- Create a measure for the number of customers.
TotalCustomer = CALCULATE(COUNTROWS('Raw Cohort data')) - Since we will rank the month values, we need to convert the Invoice date into number.
Inv_Year&Month = VALUE ( YEAR ( 'Raw Cohort data'[Invoice_Month] ) & "0" & MONTH ( 'Raw Cohort data'[Invoice_Month] ) ) - Create a column for the rank by Inv_Year&Month within Signup month. You can see the rank in below table chart.
RankInvoiceYear&Month = RANKX ( FILTER ( 'Raw Cohort data', EARLIER ( 'Raw Cohort data'[Signup Month] ) = 'Raw Cohort data'[Signup Month] ), 'Raw Cohort data'[Inv_Year&Month], , ASC, DENSE ) - Drag below data fields into the Matrix chart. Since you already know the DAX for the % view, you can replace “RankInvoiceYear&Month” with the % view DAX and then you can get another % view Matrix.
- stfox10 years agoHelper I
Thanks Simon - Just what I was after. Totally logical - when broken down into those steps
Cheers Steve
BTW - The working example is here - for anyone who requires it in the future
- ThomasDay9 years agoImpactful Individual
What a great thread. Thanks Steve for posting your finished example. Cheers! Tom
- mifo1239 years agoAdvocate II
Thank you so much! This has been really helpful! :smileyhappy:
- svishwanathan8 years agoHelper III
Hello
I am posting here cos I have a similar issue. I simply want to rank my reporting date.
Reporting date Rank
1/21/2018 0
1/19/2018 -1
1/21/2018 0
1/17/2018 -2