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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
JamesBurke
Helper II
Helper II

Rankx Ignore Blanks

Hi all , 

 

I have a condional Column that returns the device names connected to a specifc customer For example 

 

Store NameUsages
Device 112
Device 214
 14
Device 419

 

 As it's a conditonal Column it has blanks in the store name Column , which wne nranking becomes an issue

 

Rank  =
   CALCULATE(
    RANKX(
        ALL('Table1[StoreName]), // NOT ALLSELECTED
        [Total Kwh]))
 
Above is what i have so far but it includes blank in the Ranking , looking at using All( function so the device name keeps it's rank when drilled down. 
 
Desired output :
 
Rank 1 : Device 4
Rank 2 : Device 2
Rank 3 : Device 1 
 
Thanks , James.
1 ACCEPTED SOLUTION

Hi @JamesBurke ,

Sorry, please change the DAX into this:

Rank = 
VAR _RANK =
RANKX(FILTER(ALL('Table'), 'Table'[Store Name] <> BLANK()), [Measure],,DESC,Dense)
RETURN
IF(
    MAX('Table'[Store Name]) <> BLANK(),
    _RANK,
    BLANK()
)

The final output is as below:

vjunyantmsft_0-1712827165182.png


Best Regards,
Dino Tao
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

4 REPLIES 4
v-junyant-msft
Community Support
Community Support

Hi @JamesBurke ,

Please try this DAX:

Rank = 
VAR _RANK =
RANKX(ALL('Table'), [Measure],,DESC,Dense)
RETURN
IF(
    MAX('Table'[Store Name]) <> BLANK(),
    _RANK,
    BLANK()
)

vjunyantmsft_0-1712797729911.png


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

Hi @v-junyant-msft , 

 

Thanks for this ! 

 

unfortunately for me this filters the blank from the ranking but does not change the value in the sense that blank is hidden but it still effects the rankings. 

 

JamesBurke_0-1712825832071.png

Rank Test v2 =
VAR _RANK =
RANKX(ALL('Emporia Devices'[Device name KP]), [Total Kwh],,DESC,Dense)
RETURN
IF(
    MAX('Emporia Devices'[Device name KP]) <> BLANK(),
    _RANK,
    BLANK()
)
 
Is the measure im using , 
 
Thanks ! 
 

Hi @JamesBurke ,

Sorry, please change the DAX into this:

Rank = 
VAR _RANK =
RANKX(FILTER(ALL('Table'), 'Table'[Store Name] <> BLANK()), [Measure],,DESC,Dense)
RETURN
IF(
    MAX('Table'[Store Name]) <> BLANK(),
    _RANK,
    BLANK()
)

The final output is as below:

vjunyantmsft_0-1712827165182.png


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

Hi @v-junyant-msft , 

 

You are amazing , Thank you so much !! 

 

Been stuck on this an embarssing amount of time. 

 

Thanks again , James !!

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.