Forum Discussion
Rank a measure which has three tables as data source
Hello everyone,
My concern-
I have three measures Measure 1, Measure 2, Measure 3 belonging to Table 1, Table 2, Table 3 respectively.
My final measure (FinalMeasure) is basically the sum of the above three measures.
Suppose the measure represents Quantity and has corresponding items.
I want to find top 10 Items with maximum value for FinalMeasure.
I tried doing this using RANKX function but the ranks are not as expected.
Any help is greatly appreciated.
Thanks in advance.
Suguna.
4 Replies
- v-jiascu-msft
Microsoft Employee
Hi Suguna,
The measure could invoke some Tables. But a measure doesn't belong to any table. In other words, you can put it anywhere in the model.
Can you share a little sample of your data?
In your scenario, there should be a dimension table that has all the items and has relationships with the other three tables. The final visual should be the items from the dimension table and the FinalMeasure.
Best Regards,
Dale- AnonymousNot applicable
Hi Dale,
Kindly refer the screenshots below for sample data.
Item masterTable 1Table 2Tablle 3
There is one to many relationship between Item master and each of the other tables shown above.
My final measure is CALCULATE(SUM(Table1[OnHand Qty])) + CALCULATE(SUM(Table2[Ordered Qty])) - CALCULATE(SUM(Table3[OnOrder Qty]))
Now, i need to get top 10 items with maximum value for final measure. So i used
Rank = IF(HASONEVALUE(IItemMaster[ItemName]);RANKX(ALLSELECTED(ItemMaster);[Final Measure];;DESC))
IncludeTop10 = IF([Rank] <= 10; 1; 0)
Lastly, apply visual level filter on IncludeTop10 = 1.
However, this does not give the ranking as expected, in turn does not get the correct top 10 items.
Thanks,
Suguna.
- v-jiascu-msft
Microsoft Employee
Hi Suguna,
I just copied your data and formula. It works fine. Please refer to the snapshots and the demo in the attachment. One tip: the [ItemID] in the visual should be from the ItemMaster table.
Best Regards,
Dale
- v-jiascu-msft
Microsoft Employee
Hi Anonymous,
Could you please mark the proper answers as solutions?
Best Regards,
Dale