Forum Discussion
Help Pls: Comparing Items Across Two Categories with Dynamic Measures
- 2 years ago
Hi sirbaklava ,
I am unsure about the requirement but Instead of using IsInBaselineSite and IsInComparisonSite separately, create a measure that indicates whether the item is missing in either of the sites. This will help in identifying discrepancies more clearly
ItemComparisonStatus = VAR IsInBaseline = CALCULATE( COUNTROWS('sample_data'), 'sample_data'[site] = SELECTEDVALUE('sample_data'[site]) && 'sample_data'[item] = SELECTEDVALUE('sample_data'[item]) ) > 0 VAR IsInComparison = CALCULATE( COUNTROWS('sample_data'), 'sample_data'[site] = SELECTEDVALUE('sample_data'[site]) && 'sample_data'[item] = SELECTEDVALUE('sample_data'[item]) ) > 0 RETURN SWITCH( TRUE(), NOT IsInBaseline && IsInComparison, "In Comparison Only", IsInBaseline && NOT IsInComparison, "In Baseline Only", "In Both" ) - Anonymous2 years ago
Hi, sirbaklava
Perhaps you can use another method to accomplish your needs that does not require the 'Edit interactons' feature.
First you need to create two tables 'se1' and 'se2' via New table:
se1 = 'sample_data'se2 = 'sample_data'Then create two corresponding Measures in both tables to show which site is selected in Card visual.
Table se1:
SelectedBaselineSite = SELECTEDVALUE ( se1[site] )Table se2:
SelectedComparisonSite = SELECTEDVALUE ( se2[site] )Create another Measure to get all the items corresponding to the sites selected by slicer:
All Item = VAR select3 = SELECTEDVALUE ( 'se2'[site] ) VAR select4 = SELECTEDVALUE ( 'se1'[site] ) RETURN IF ( MAX ( 'sample_data'[item] ) = CALCULATE ( MAX ( sample_data[item] ), FILTER ( 'sample_data', 'sample_data'[site] = select3 || 'sample_data'[site] = select4 ) ), 1, 0 )Finally, a Measure is created to check if there are identical items in the two sites being compared, returning 'true' if there are identical items and 'false' if there are not.
ItemComparison = VAR select1 = SELECTEDVALUE ( 'se1'[site] ) VAR select2 = SELECTEDVALUE ( 'se2'[site] ) VAR ID1 = CALCULATETABLE ( VALUES ( 'sample_data'[item] ), FILTER ( ALLSELECTED ( 'sample_data' ), 'sample_data'[site] = select1 ) ) VAR ID2 = CALCULATETABLE ( VALUES ( 'sample_data'[item] ), FILTER ( ALLSELECTED ( 'sample_data' ), 'sample_data'[site] = select2 ) ) RETURN MAX ( 'sample_data'[item] ) IN INTERSECT ( ID1, ID2 )This is the final result.
I have appended the .pbix file to the end, I hope this helps.
I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi sirbaklava ,
I am unsure about the requirement but Instead of using IsInBaselineSite and IsInComparisonSite separately, create a measure that indicates whether the item is missing in either of the sites. This will help in identifying discrepancies more clearly
ItemComparisonStatus =
VAR IsInBaseline =
CALCULATE(
COUNTROWS('sample_data'),
'sample_data'[site] = SELECTEDVALUE('sample_data'[site]) &&
'sample_data'[item] = SELECTEDVALUE('sample_data'[item])
) > 0
VAR IsInComparison =
CALCULATE(
COUNTROWS('sample_data'),
'sample_data'[site] = SELECTEDVALUE('sample_data'[site]) &&
'sample_data'[item] = SELECTEDVALUE('sample_data'[item])
) > 0
RETURN
SWITCH(
TRUE(),
NOT IsInBaseline && IsInComparison, "In Comparison Only",
IsInBaseline && NOT IsInComparison, "In Baseline Only",
"In Both"
)