Forum Discussion
Anonymous
7 years agoNot applicable
DAX logical AND condition based on multiple selection
Hi, Lets say this is a sample of my data. I have a slicer that allows to choose multiple values based on FailureCode column. One Session can have multiple FailureCodes. What I need to achieve, is...
Anonymous
7 years agoNot applicable
Mate, first of all, measures do not return tables. Only single values.
Second of all, here's a measure that will tell you for each session whether it has all the codes selected in your dimension:
[Session Has All Selected Codes] = var __visibleFailureCodes = VALUES ( FailureCodes[FailureCode] ) -- note the "s" on the end (dims should end in "s") var __numOfVisibleCodes = COUNTROWS ( __visibleFailureCodes ) var __oneSessionVisible = HASONEVALUE ( FactTable[Session] ) var __existingCodesForSession = CALCULATETABLE ( VALUES ( FactTable[FailureCode] ), VALUES ( FactTable[Session] ), __visibleFailureCodes, ALL ( FactTable ) ) var __numOfExistingCodes = COUNTROWS ( __existingCodesForSession ) var __sessionHasAllSelectedCodes = ( __numOfExistingCodes = __numOfVisibleCodes ) return if ( __oneSessionVisible, __sessionHasAllSeletedCodes )
Best
Darek