Forum Discussion
Adding Condition to Switch Measure to Output "0"
Hi! Need to add a condition to my Switch measure "Total Dynamic Calls"
I want it to output "0" for SUM of [Total Calls] from the 'Combined Call Logs 5/17' table if the value "Field" from the UpdatedProd521 [Enrollment Type] table is selected in a slicer.
Otherwise, it should output SUM Total Calls if the value "Call Center" is selected. Thanks in advance!
Here is the current Switch measure:
Hi jabueg,
This can be achieved by using the SELECTEDVALUE() function to determine which value is currently selected in the slicer. The measure below checks for a specific selection and adjusts the output accordingly:Total Calls Dynamic = VAR IsFieldSelected = SELECTEDVALUE(UpdatedProd521[Enrollment Type]) = "Field" RETURN IF ( IsFieldSelected, 0, SWITCH( TRUE(), // Case 1: Single Advisor AND Single Date selected HASONEVALUE(UpdatedProd521[Advisor]) && HASONEVALUE(UpdatedProd521[Date]), CALCULATE( SUM('Combined Call Logs 5/17'[CALLS]), USERELATIONSHIP(UpdatedProd521[Advisor], 'Combined Call Logs 5/17'[ADVISOR]), FILTER( 'Combined Call Logs 5/17', 'Combined Call Logs 5/17'[DATE] = VALUES(UpdatedProd521[Date]) ) ), // Case 2: Only Advisor is selected HASONEVALUE(UpdatedProd521[Advisor]), CALCULATE( SUM('Combined Call Logs 5/17'[CALLS]), USERELATIONSHIP(UpdatedProd521[Advisor], 'Combined Call Logs 5/17'[ADVISOR]) ), // Case 3: Only Date is selected HASONEVALUE(UpdatedProd521[Date]), CALCULATE( SUM('Combined Call Logs 5/17'[CALLS]), USERELATIONSHIP('Combined Call Logs 5/17'[DATE], UpdatedProd521[Date]) ), // Default: sum all calls if no or multiple selections SUM('Combined Call Logs 5/17'[CALLS]) ) )If this helped, please mark it as the solution so others can benefit too. And if you found it useful, kudos are always appreciated.
Thanks,Samson
4 Replies
- SamsonTruong
Super User
Hi jabueg,
This can be achieved by using the SELECTEDVALUE() function to determine which value is currently selected in the slicer. The measure below checks for a specific selection and adjusts the output accordingly:Total Calls Dynamic = VAR IsFieldSelected = SELECTEDVALUE(UpdatedProd521[Enrollment Type]) = "Field" RETURN IF ( IsFieldSelected, 0, SWITCH( TRUE(), // Case 1: Single Advisor AND Single Date selected HASONEVALUE(UpdatedProd521[Advisor]) && HASONEVALUE(UpdatedProd521[Date]), CALCULATE( SUM('Combined Call Logs 5/17'[CALLS]), USERELATIONSHIP(UpdatedProd521[Advisor], 'Combined Call Logs 5/17'[ADVISOR]), FILTER( 'Combined Call Logs 5/17', 'Combined Call Logs 5/17'[DATE] = VALUES(UpdatedProd521[Date]) ) ), // Case 2: Only Advisor is selected HASONEVALUE(UpdatedProd521[Advisor]), CALCULATE( SUM('Combined Call Logs 5/17'[CALLS]), USERELATIONSHIP(UpdatedProd521[Advisor], 'Combined Call Logs 5/17'[ADVISOR]) ), // Case 3: Only Date is selected HASONEVALUE(UpdatedProd521[Date]), CALCULATE( SUM('Combined Call Logs 5/17'[CALLS]), USERELATIONSHIP('Combined Call Logs 5/17'[DATE], UpdatedProd521[Date]) ), // Default: sum all calls if no or multiple selections SUM('Combined Call Logs 5/17'[CALLS]) ) )If this helped, please mark it as the solution so others can benefit too. And if you found it useful, kudos are always appreciated.
Thanks,Samson
- 123abc
Community Champion
Kudo 👌
- jabueg
Helper I
SamsonTruong This worked perfectly. Thanks, Samson!
- SamsonTruong
Super User
jabueg glad to hear it worked!