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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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

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
v-yangliu-msft
Community Support
Community Support

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

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.