Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
This works while SelectedBranch and SelectedCompany have a value selected from each corresponding slicer. The issue arises when either SelectedBranch or SelectedCompany is selected or none at all. I've tried writing a nested if to cater for it but there has got to be a simplier method.
Active = VAR SelectedBranch = SELECTEDVALUE(Companies[cBranch]) VAR SelectedCompany = SELECTEDVALUE(Companies[coid]) Return CALCULATE(countrows(messages), Messages[mMessageType]<>1, FILTER(ALL(Messages), Messages[coid]=SelectedCompany), FILTER(ALL(Messages), Messages[mRegion]=SelectedBranch), FILTER(ALL(Messages), [mtimeofmsg]<=MIN(DateKey[Date])), FILTER(ALL(Messages), [DateCompleted]>=MIN(DateKey[Date])))
Solved! Go to Solution.
Active = VAR SelectedBranch = SELECTEDVALUE ( Companies[cBranch] ) VAR SelectedCompany = SELECTEDVALUE ( Companies[coid] ) RETURN CALCULATE ( COUNTROWS ( messages ), Messages[mMessageType] <> 1, FILTER ( ALL ( Messages ), IF ( ISBLANK ( SelectedCompany ), TRUE (), Messages[coid] = SelectedCompany ) ), FILTER ( ALL ( Messages ), IF ( ISBLANK ( SelectedBranch ), TRUE (), Messages[mRegion] = SelectedBranch ) ), FILTER ( ALL ( Messages ), [mtimeofmsg] <= MIN ( DateKey[Date] ) ), FILTER ( ALL ( Messages ), [DateCompleted] >= MIN ( DateKey[Date] ) ) )
Please mark the question solved when done and consider giving kudos if posts are helpful.
Cheers
Hi @frigus
I cannot help much cause you don't explain what exactly you would want to do in that case
SELECTEDVALUE( ) has a second parameter that you can use to return a value when there's multiple or no selections.
VAR SelectedBranch = SELECTEDVALUE(Companies[cBranch], ReturnValue when multiple selection here)
Please mark the question solved when done and consider giving kudos if posts are helpful.
Cheers
Thanks for your assistance.
If there is multiple or no selections, I'd like no filter to be applied at all e.g. in theory, this portion of the dax would be excluded.
FILTER(ALL(Messages), Messages[coid]=SelectedCompany)
Thanks.
Active = VAR SelectedBranch = SELECTEDVALUE ( Companies[cBranch] ) VAR SelectedCompany = SELECTEDVALUE ( Companies[coid] ) RETURN CALCULATE ( COUNTROWS ( messages ), Messages[mMessageType] <> 1, FILTER ( ALL ( Messages ), IF ( ISBLANK ( SelectedCompany ), TRUE (), Messages[coid] = SelectedCompany ) ), FILTER ( ALL ( Messages ), IF ( ISBLANK ( SelectedBranch ), TRUE (), Messages[mRegion] = SelectedBranch ) ), FILTER ( ALL ( Messages ), [mtimeofmsg] <= MIN ( DateKey[Date] ) ), FILTER ( ALL ( Messages ), [DateCompleted] >= MIN ( DateKey[Date] ) ) )
Please mark the question solved when done and consider giving kudos if posts are helpful.
Cheers
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
100 | |
80 | |
63 | |
58 |
User | Count |
---|---|
148 | |
111 | |
94 | |
84 | |
67 |