Forum Discussion
Switch not working properly
I'd like to sum columns from differents tables depending of the filter i apply :
- If i select "CRC1", i'd like to sum the amount of calls registered in the table "CRC1 - NB APPELS".
- If i select "CRC 2", i'd like to sum the amount of calls registered in the table "CRC2 - NB APPELS".
etc
I did this measure :
But it only give me results for the first statement (CRC1).
Thank you for your help !
Hi HugoREGIS -can you cross check once on, if all tables (CRC1 - NB APPELS, CRC2 - NB APPELS, etc.) have valid relationships with the filter table (Table correspondance CRC), or that they're all independent.
check the Modified measure:
Measure Call Count =
SWITCH(
TRUE(),
SELECTEDVALUE('Table correspondance CRC'[Type]) = "CRC 1", CALCULATE(SUM('CRC1 - NB APPELS'[Nombre d'appels externes])),
SELECTEDVALUE('Table correspondance CRC'[Type]) = "CRC 2", CALCULATE(SUM('CRC2 - NB APPELS'[Nombre d'appels externes])),
SELECTEDVALUE('Table correspondance CRC'[Type]) = "CRC 3", CALCULATE(SUM('CRC3 - NB APPELS'[Nombre d'appels externes])),
SELECTEDVALUE('Table correspondance CRC'[Type]) = "CRC 4", CALCULATE(SUM('CRC4 - NB APPELS'[Nombre d'appels externes])),
SELECTEDVALUE('Table correspondance CRC'[Type]) = "CRC 5", CALCULATE(SUM('CRC5 - NB APPELS'[Nombre d'appels externes])),
SELECTEDVALUE('Table correspondance CRC'[Type]) = "REP 1", CALCULATE(SUM('REP1 - NB APPELS'[Nombre d'appels externes])),
SELECTEDVALUE('Table correspondance CRC'[Type]) = "REP 2", CALCULATE(SUM('REP2 - NB APPELS'[Nombre d'appels externes])),
"Non attribué"
)Let me know if this resolves your issue or if there’s something else to investigate!
- Anonymous1 year ago
Hi HugoREGIS
Thanks for the reply from rajendraongole1 , FlipFlop1 and Tahreem24 .
Did rajendraongole1 's and FlipFlop1 's methods solve your problem? If yes, could you please mark them as solutions? This will be of great help to other users experiencing similar problems. Thank you!
In my test, the tables can be calculated normally regardless of whether there is a relationship between them. The following is my test for your reference.
My sample:
Measure:
Measure = SWITCH(TRUE(), SELECTEDVALUE(Slicer[Category]) = "A", SUM('A Table'[Value]), SELECTEDVALUE(Slicer[Category]) = "B", SUM('B Table'[Value]) )Output:
1. no relationships
2. have relationships
Best Regards,
Yulia XuIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 Replies
- rajendraongole1Super User
Hi HugoREGIS -can you cross check once on, if all tables (CRC1 - NB APPELS, CRC2 - NB APPELS, etc.) have valid relationships with the filter table (Table correspondance CRC), or that they're all independent.
check the Modified measure:
Measure Call Count =
SWITCH(
TRUE(),
SELECTEDVALUE('Table correspondance CRC'[Type]) = "CRC 1", CALCULATE(SUM('CRC1 - NB APPELS'[Nombre d'appels externes])),
SELECTEDVALUE('Table correspondance CRC'[Type]) = "CRC 2", CALCULATE(SUM('CRC2 - NB APPELS'[Nombre d'appels externes])),
SELECTEDVALUE('Table correspondance CRC'[Type]) = "CRC 3", CALCULATE(SUM('CRC3 - NB APPELS'[Nombre d'appels externes])),
SELECTEDVALUE('Table correspondance CRC'[Type]) = "CRC 4", CALCULATE(SUM('CRC4 - NB APPELS'[Nombre d'appels externes])),
SELECTEDVALUE('Table correspondance CRC'[Type]) = "CRC 5", CALCULATE(SUM('CRC5 - NB APPELS'[Nombre d'appels externes])),
SELECTEDVALUE('Table correspondance CRC'[Type]) = "REP 1", CALCULATE(SUM('REP1 - NB APPELS'[Nombre d'appels externes])),
SELECTEDVALUE('Table correspondance CRC'[Type]) = "REP 2", CALCULATE(SUM('REP2 - NB APPELS'[Nombre d'appels externes])),
"Non attribué"
)Let me know if this resolves your issue or if there’s something else to investigate!
- FlipFlop1Advocate I
Try:
Measure =
VAR Type = SELECTEDVALUE('Table correspondance CRC'[Type])
RETURNSWITCH(Type,"CRC 1", SUM('CRC1 - NB APPELS'[Nombre d'appels externes]),"CRC 2", SUM('CRC2 - NB APPELS'[Nombre d'appels externes]),"CRC 3", SUM('CRC3 - NB APPELS'[Nombre d'appels externes]),"CRC 4", SUM('CRC4 - NB APPELS'[Nombre d'appels externes]),"CRC 5", SUM('CRC5 - NB APPELS'[Nombre d'appels externes]),"REP 1", SUM('REP1 - NB APPELS'[Nombre d'appels externes]),"REP 2", SUM('REP2 - NB APPELS'[Nombre d'appels externes]),"Non attribué") - AnonymousNot applicable
Hi HugoREGIS
Thanks for the reply from rajendraongole1 , FlipFlop1 and Tahreem24 .
Did rajendraongole1 's and FlipFlop1 's methods solve your problem? If yes, could you please mark them as solutions? This will be of great help to other users experiencing similar problems. Thank you!
In my test, the tables can be calculated normally regardless of whether there is a relationship between them. The following is my test for your reference.
My sample:
Measure:
Measure = SWITCH(TRUE(), SELECTEDVALUE(Slicer[Category]) = "A", SUM('A Table'[Value]), SELECTEDVALUE(Slicer[Category]) = "B", SUM('B Table'[Value]) )Output:
1. no relationships
2. have relationships
Best Regards,
Yulia XuIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.