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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Jessie_Ip
Regular Visitor

RANKX shows all 1 even if I use ALL at table and CALCULATE

Hi there,

 

I have issue for RANKX.

 

All fields are from same table with below column:

DOD - a date with year, quarter, month, day

 

I want to rank the count of DOD by monthly basis and sort from Jan to Dec. The Month column is from DOD.

Here's the DAX: 

DoD Rank =
RANKX(ALL(BEREAVEMENTRAW), CALCULATE(COUNT(BEREAVEMENTRAW[DOD].[Date])),,desc,Dense)

 

Jessie_Ip_0-1707235115649.png

I've already used ALL at table and CALCULATE to do the context transition. any advise why it still show 1 for all?

 

Many thanks,

Jessie

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @Jessie_Ip 

Thank you for your reply. I understand your concerns, so I came up with a new way to calculate rankings. I created a new summary table through SUMMARIZE, and calculated the correct ranking through this summary table. According to your description DOD is date type data, I created the following data:

vjianpengmsft_0-1708416913144.png

Create a new calculation table using the following DAX expression:

Table=SUMMARIZE (
    'Sheet5',
    Sheet5[Date].[Month],
    "Count DOD", CALCULATE ( COUNT ( 'Sheet5'[DOD] ), MONTH ( 'Sheet5'[DOD] ) )
)

The summary results are as follows:

vjianpengmsft_1-1708417071651.png

Create a new column in this table for ranking. The DAX expression is as follows:

Rank = RANKX('Table','Table'[Count DOD],,DESC,Dense)

Ranking as follows:

vjianpengmsft_4-1708417573186.png

 

Put this column into table visual:

vjianpengmsft_5-1708417594735.png

I've provided the PBIX file used this time below. If you have any questions please let me know and I'll be happy to answer them.

 

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

7 REPLIES 7
vivek31
Resolver II
Resolver II

DoD Rank =
RANKX(ALL(BEREAVEMENTRAW[month])CALCULATE(COUNT(BEREAVEMENTRAW[DOD].[Date])),,desc,Dense)
Jessie_Ip
Regular Visitor

Hi @bhanu_gautam ,

 

I have tried as below:

DoD Rank =
RANKX(
    ALL(BEREAVEMENTRAW[DOD]),
    CALCULATE(
        COUNTROWS(BEREAVEMENTRAW),
        BEREAVEMENTRAW[DOD].[Month]), ,desc,Dense)
 
but it shows:
 
9.PNG

 i check DOD and it's datetime format as '25/02/2020 00:00:00' not value January. Any advise?

 

Thanks,

Jessie

Anonymous
Not applicable

Hi, @Jessie_Ip 

 

I'm happy to answer your questions. We can achieve ranking by calculating columns and measures:

1.Implemented through measure

We need to create two measures, measure2 is used to aggregate Count of DOD, measure is used to rank

Measure2 DAX formula:

Measure 2 = SUM(Sheet3[Count of DOD])

Measure DAX formula:

Measure = CALCULATE(RANKX(ALL('Sheet3'),[Measure 2],,DESC,Dense))

The results are as follows:

7.png

2.Ranking is achieved by calculate columns:

Calculate columns DAX formula

Column = RANKX(ALL(Sheet3),Sheet3[Count of DOD],,DESC,Dense)

The results are as follows:

7.png

I have provided the sample PBIX file used this time below. If the above suggestions are helpful to you, that would be great.

 

 

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @Anonymous 

 

Thank you for reply. DOD is a date so i use count as below:

COUNT_DOD = CALCULATE(COUNT(BEREAVEMENTRAW[DOD]), MONTH(BEREAVEMENTRAW[DOD]))
 
Then follow your way:
RANKX_DOD = CALCULATE(RANKX(ALL(BEREAVEMENTRAW), [COUNT_DOD],, DESC, Dense))
 
And it still show 
Jessie_Ip_0-1708013454487.png

 

DOD is like this format: 25/02/2020 00:00:00

 

Any advise?

 

From what i find, I can't share the pbix file. If you can advise other way to share the file, I can try!

 

Many thanks,

Jessie

Anonymous
Not applicable

Hi, @Jessie_Ip 

Thank you for your reply. I understand your concerns, so I came up with a new way to calculate rankings. I created a new summary table through SUMMARIZE, and calculated the correct ranking through this summary table. According to your description DOD is date type data, I created the following data:

vjianpengmsft_0-1708416913144.png

Create a new calculation table using the following DAX expression:

Table=SUMMARIZE (
    'Sheet5',
    Sheet5[Date].[Month],
    "Count DOD", CALCULATE ( COUNT ( 'Sheet5'[DOD] ), MONTH ( 'Sheet5'[DOD] ) )
)

The summary results are as follows:

vjianpengmsft_1-1708417071651.png

Create a new column in this table for ranking. The DAX expression is as follows:

Rank = RANKX('Table','Table'[Count DOD],,DESC,Dense)

Ranking as follows:

vjianpengmsft_4-1708417573186.png

 

Put this column into table visual:

vjianpengmsft_5-1708417594735.png

I've provided the PBIX file used this time below. If you have any questions please let me know and I'll be happy to answer them.

 

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Nathan321
Frequent Visitor

The All(Berevementraw) needs a column reference, such as ALL(BEREVEMENT[DOD])

bhanu_gautam
Super User
Super User

@Jessie_Ip , Try using below method 

 

DoD Rank =
RANKX(
ALL(BEREAVEMENTRAW[DOD]),
CALCULATE(
COUNTROWS(BEREAVEMENTRAW),
BEREAVEMENTRAW[DOD].[Month]
),
,
DESC,
Dense
)

 

Please accept as solution and give kudos if it helps




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.