Forum Discussion
Anonymous
5 years agoNot applicable
SUM excluding IDs from Other column in the same table
Hi all, Maybe this is super simple but I just can't figure it out. I have a slicer with multi selection available, when a single Country is selected it should SUM everything in Values just normal...
- Anonymous5 years ago
Hi Anonymous ,
Please check the attachment.
1.Create a seperate countryname table.
2.Create two measures.
flag = VAR _allID = SUMMARIZE ( FILTER ( ALL ( 'Table' ), 'Table'[CountryName] IN ALLSELECTED ( 'Table 2'[CountryName] ) ), 'Table'[CountryID] ) VAR _flag = IF ( MAX ( 'Table'[ReferenceCountryID] ) IN _allID && MAX ( 'Table'[CountryName] ) IN ALLSELECTED ( 'Table 2'[CountryName] ), SUM ( 'Table'[Values] ) ) RETURN _flagOutput = VAR _countSele = COUNTX ( FILTER ( 'Table', 'Table'[CountryName] IN ALLSELECTED ( 'Table'[CountryName] ) ), [CountryName] ) VAR _sum = CALCULATE ( SUM ( 'Table'[Values] ), FILTER ( 'Table', 'Table'[CountryName] IN ALLSELECTED ( 'Table 2'[CountryName] ) ) ) RETURN IF ( _countSele = 1, _sum, _sum - SUMX ( 'Table', [flag] ) )Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
5 years agoNot applicable
Hi Anonymous ,
Please check the attachment.
1.Create a seperate countryname table.
2.Create two measures.
flag =
VAR _allID =
SUMMARIZE (
FILTER (
ALL ( 'Table' ),
'Table'[CountryName] IN ALLSELECTED ( 'Table 2'[CountryName] )
),
'Table'[CountryID]
)
VAR _flag =
IF (
MAX ( 'Table'[ReferenceCountryID] )
IN _allID
&& MAX ( 'Table'[CountryName] ) IN ALLSELECTED ( 'Table 2'[CountryName] ),
SUM ( 'Table'[Values] )
)
RETURN
_flag
Output =
VAR _countSele =
COUNTX (
FILTER ( 'Table', 'Table'[CountryName] IN ALLSELECTED ( 'Table'[CountryName] ) ),
[CountryName]
)
VAR _sum =
CALCULATE (
SUM ( 'Table'[Values] ),
FILTER (
'Table',
'Table'[CountryName] IN ALLSELECTED ( 'Table 2'[CountryName] )
)
)
RETURN
IF ( _countSele = 1, _sum, _sum - SUMX ( 'Table', [flag] ) )
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.