Forum Discussion
Required Unique data when 2 tables are merged
Hi,
I have below 2 tables - SOH table (no unique rows) & Order (no unique rows)
SOH:
| Item# | SOH | Site Location |
| A | 6 | XY |
| A | 3 | OO |
| B | 9 | XY |
| B | 12 | DD |
Order:
Result required as below, if no site selected:
if site "XY" selected then required below result:
Thanks in advance.
Hi vkoukuntla - Ok , Can you please try the below one
it works
Total SOH =VAR SelectedSite = SELECTEDVALUE('Ordert'[Site Location])RETURNIF(ISBLANK(SelectedSite),CALCULATE(SUMX(VALUES('Ordert'[Item#]),CALCULATE(SUM('Ordert'[SOH])))),CALCULATE(SUM('Ordert'[SOH]),'Ordert'[Site Location] = SelectedSite))Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
4 Replies
- rajendraongole1
Super User
Hi vkoukuntla - Create a measure to calculate the total SOH based on the selected site or overall.
i have used merge transformation to ordertable:
quantity dont summarize on your table chart.
use below measure
with XY selection:
Total SOH =VAR SelectedSite = SELECTEDVALUE('Ordert'[Site Location])RETURNIF(ISBLANK(SelectedSite),CALCULATE(SUM('Ordert'[SOH]),ALLEXCEPT('Ordert', 'Ordert'[Item#])),CALCULATE(SUM('Ordert'[SOH]),'Ordert'[Site Location] = SelectedSite))without XY Selection
Hope it works
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!! - vkoukuntlaNew Member
Thank you Rajendra, however when you unselect XY site, the total SOH for item A should be 9, in your example it shows qty: 18
- rajendraongole1
Super User
Hi vkoukuntla - Ok , Can you please try the below one
it works
Total SOH =VAR SelectedSite = SELECTEDVALUE('Ordert'[Site Location])RETURNIF(ISBLANK(SelectedSite),CALCULATE(SUMX(VALUES('Ordert'[Item#]),CALCULATE(SUM('Ordert'[SOH])))),CALCULATE(SUM('Ordert'[SOH]),'Ordert'[Site Location] = SelectedSite))Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!! - Irwan
Super User
hello vkoukuntla
this is not merging two table, instead using measure.
the merge table and Order table are looking similarly.
1. Create a new measure with following DAX:
SOH =
var _Item = SELECTEDVALUE('Table 2'[Item#])
Return
SUMX(FILTER('Table 1','Table 1'[Item#]=_Item),'Table 1'[SOH])2. Plot 'Order' data in Table visual including measure above with 'Site Location' slicer.Hope this will help you.Thank you.