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
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

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

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Power BI Monthly Update - May 2024

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