Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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.
Solved! Go to 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.
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.
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.
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 :
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.
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.
Sorry for little late reply. It worked thank you 🙂
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.
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.
@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
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 :
@Anonymous , try to add this filter and check-in calculate
filter(FactFigures, not(isblank(related(AUXCategoryOrderDeptT [Category ID] ))))
Try and check
I have used as said