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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

RankX measure giving blank on non matched values

Hi , 
I am creating a measure to calculate Rank of Table1'Category_Name' based upon sum of column Table2'Realized_Cost' in another table. The two tables have one to many relationship where all 'Category_Name' in Table2 aren't present in Table that is 'Table1'Category_Name has fewer values than 'Table2'Category hence giving a blank row in the result :

rank x.pngI want to have Rank against only those values that are present in both tables so that no blanks are there. I think something like LookUpValue , Related or Filter or AllNOBLANKROWS needs to be used but it is not working for me or I don't know how to write. 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Anonymous ,

Here are the steps you can follow:

According to the pbix you created:

1. Create calculated column.

Sum =
CALCULATE(SUM('Table'[Cost]),FILTER(ALL('Table'),'Table'[Category_Name]=EARLIER('Table (2)'[Category_Name])))
Rankl =
var _rank=
RANKX(FILTER('Table (2)',[Sum]<>BLANK()),[Sum],,DESC,Dense)
return
IF([Sum]=BLANK(),99,_rank)

2. Result.

v-yangliu-msft_0-1610598758053.png

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

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

10 REPLIES 10
Anonymous
Not applicable

Hi  @Anonymous ,

You try to change measure to this

Category Rank 5 Department Report=
Var _1= If(SELECTVALUE(‘AUXCategoryOrderDeptT’[Category Name])=”Others”,5+1,RANKX(ALL(‘AUXCategoryOrderDeptT’[Category Name]),CALCULATE(SUM(‘FactFigures DKK’[Realized Cost]))))
return
If (max([category name])=blank(),blank(),_1)

If my answer is not what you need, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Best Regards,

Liu Yang

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

 

Anonymous
Not applicable

Thank you for your response. The solution you proposed is still ranking the categories that are not part of table 'AUXCategoryOrderDeptT' table but giving the rank as blank and skipping the rank in remaining categories  :

RANKX power bi.png

 

I want A B C to have rank as 3 1 2 or so  .  it is so irritating that we can't attach the pbix file here .
the small example I have created in pbix file :

1.png2.png3.png

Anonymous
Not applicable

Hi  @Anonymous ,

Here are the steps you can follow:

According to the pbix you created:

1. Create calculated column.

Sum =
CALCULATE(SUM('Table'[Cost]),FILTER(ALL('Table'),'Table'[Category_Name]=EARLIER('Table (2)'[Category_Name])))
Rankl =
var _rank=
RANKX(FILTER('Table (2)',[Sum]<>BLANK()),[Sum],,DESC,Dense)
return
IF([Sum]=BLANK(),99,_rank)

2. Result.

v-yangliu-msft_0-1610598758053.png

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

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

Anonymous
Not applicable

Sorry for little late reply. It worked thank you 🙂 

PC2790
Community Champion
Community Champion

For a straight forward way, you can apply the visual level or page level filter from the right pane on the Category Name where the Category Name is not blank. For the solution from DAX perspective, can you please share your pbix file so that I can try implementing it.

Anonymous
Not applicable

Blank is not part of the column 'Category_Name' and I am going to use this measure in another measure . The blank appears because of some values not present in second tables. I cannot share the pbix due to big size of file and privacy issues.

amitchandak
Super User
Super User

@Anonymous , In rankx In place of all try allselected.

Also, check why you have a category missing, this seems like there category in Fact figures and not there in category table.

if this a blank because of blank realized cost then filter that in calculate

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

thank you for your quick respone. Allselected is giving the same result.

And yes like I have mentioned Fact Figures are having extra Category Name which are not present in AUXCategoryOrderDeptT table. And also Realized Cost in not BLANK :

rank x 2.png

@Anonymous , try to add this filter and check-in calculate

filter(FactFigures, not(isblank(related(AUXCategoryOrderDeptT [Category ID] ))))

 

Try and check

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

I have used as said 

Category Rank 5 Department Report =
IF(SELECTEDVALUE('AUXCategoryOrderDeptT'[Category Name]) = "Others", 5 + 1, RANKX(ALLSELECTED('AUXCategoryOrderDeptT'[Category Name] ) ,CALCULATE(SUM('FactFigures DKK'[Realized Cost]) , filter('FactFigures DKK', not(isblank(related(AUXCategoryOrderDeptT[Category Name] )))))))


Blank is still there and now it is giving these weird 1s as a Rank against all category Name :

rank x 3.png

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.