cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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 :

I 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
Community Support

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.

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.

10 REPLIES 10
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  :

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 :

Community Support

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.

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 🙂

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.

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 :

Super User

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

Announcements

#### New forum boards available in Real-Time Intelligence.

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

#### Power BI Monthly Update - May 2024

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

#### Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors