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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
DivyaReddy
Frequent Visitor

Need RANKX to exclude Blanks

Dear PBI enthusiasts!

I am relatively new to PowerBI and struggling through this one scenario. Use case - 

  1. I have a parameter (type of customer - Domestic / International / Contractors) and depending on what the user chooses, I need to use that as my column. There is a TotalSales calculated DAX which is UnitPrice*Qty. 
  2. Super simple:) However I need to show only top 5 AND exclude any blanks. 
  3. I got the Top5 using RankX, but not able to exclude blanks - tried many things, so would greatly apprciate your help. I have attached a sample PBXI file. (Hmm...not sure how to insert the test file...)

Thank you in advance!

<bottom> 

2 REPLIES 2
v-xiaotang
Community Support
Community Support

Hi @DivyaReddy 

Thanks for reaching out to us.

I just want to confirm if you resolved this issue? If yes, you can accept the answer helpful as the solution or share you method and accept it as solution, thanks for your contribution to improve Power BI.

If you need more help, please let me know.

 

Best Regards,

Community Support Team _Tang

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

daXtreme
Solution Sage
Solution Sage

In the RANKX function, don't use the whole table as the first argument but FILTER it by the cells/entries that don't have BLANKs. That's also simple. And if the cell is BLANK, just don't calculate the rank. Something like:

[Ranking] = 
var AllItemsNonBlank = 
    filter(
        // Due to ALLSELECTED this is a relatve
        // ranking. If you want an absolute ranking,
        // use ALL( T[Item] ) instead.
        allselected( T[Item] ),
        not isblank( [your measure to rank with] )
    )
var Result =
    if( not isblank( [your measure to rank with] ),
        rankx(
            AllItemsNonBlank,
            [your measure to rank with]
        )
    )
return
    Result

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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