Forum Discussion
UNION Filtered Data and then RANKX
- 4 years ago
Hi Anonymous
Try this,
DAX code:
Measure = var __category = SELECTEDVALUE(Table1[Category]) var __table1 = SELECTCOLUMNS(Table1,"Company",Table1[Company],"Category",Table1[Category],"Value",Table1[value]) var __table2 = SELECTCOLUMNS(FILTER(Table2,Table2[Category]=__category),"Company",Table2[Company],"Category",Table2[Category],"Value",Table2[Value]) var __table3 = UNION(__table1,__table2) var __table4 = ADDCOLUMNS(__table3,"rank",RANKX(__table3,[Value],,ASC)) return MAXX(FILTER(__table4,[Company]=SELECTEDVALUE(Table1[Company])),[rank])This measure is designed based on the sample data and expected results you provide. If requirements change, you can adjust the measure .
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
Hi Anonymous
Can you add more details re how you find the rank numbers in the result table?
It's not that clear!
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
Hi,
It is the rank looking at the values, higher the value higher the rank.
I was trying to do this
r des =
var tb = union(SUMMARIZE('Table 2',"category",MAX('Table 2'[category]),"company",max('Table 2'[company]),"value",sum('Table 2'[value])),
SUMMARIZE('Table 1',"category",MAX('Table 1'[category]),"company",max('Table 1'[company]),"value",sum('Table 1'[value]))
)
return RANKX(tb,[value],,0)
But it says that there is no value on "value"
Thank you