Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
HugoREGIS
Regular Visitor

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 :

SWITCH(
TRUE(),
SELECTEDVALUE('Table correspondance CRC'[Type]) = "CRC 1", SUM('CRC1 - NB APPELS'[Nombre d'appels externes]),
SELECTEDVALUE('Table correspondance CRC'[Type]) = "CRC 2", SUM('CRC2 - NB APPELS'[Nombre d'appels externes]),
SELECTEDVALUE('Table correspondance CRC'[Type]) = "CRC 3", SUM('CRC3 - NB APPELS'[Nombre d'appels externes]),
SELECTEDVALUE('Table correspondance CRC'[Type]) = "CRC 4", SUM('CRC4 - NB APPELS'[Nombre d'appels externes]),
SELECTEDVALUE('Table correspondance CRC'[Type]) = "CRC 5", SUM('CRC5 - NB APPELS'[Nombre d'appels externes]),
SELECTEDVALUE('Table correspondance CRC'[Type]) = "REP 1", SUM('REP1 - NB APPELS'[Nombre d'appels externes]),
SELECTEDVALUE('Table correspondance CRC'[Type]) = "REP 2", SUM('REP2 - NB APPELS'[Nombre d'appels externes]),
"Non attribué"
)

But it only give me results for the first statement (CRC1).

Thank you for your help !
2 ACCEPTED SOLUTIONS
rajendraongole1
Super User
Super 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!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

v-xuxinyi-msft
Community Support
Community Support

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:

vxuxinyimsft_0-1727431048024.png

 

vxuxinyimsft_1-1727431065476.png

 

vxuxinyimsft_2-1727431085106.png

 

Measure:

 

 

Measure = SWITCH(TRUE(),
SELECTEDVALUE(Slicer[Category]) = "A", SUM('A Table'[Value]), 
SELECTEDVALUE(Slicer[Category]) = "B", SUM('B Table'[Value])
)

 

 

 

Output:

 

1. no relationships

vxuxinyimsft_3-1727431235538.png

 

vxuxinyimsft_4-1727431253345.png

 

vxuxinyimsft_5-1727431264296.png

 

2. have relationships

vxuxinyimsft_6-1727431305811.png

 

vxuxinyimsft_7-1727431328558.png

 

vxuxinyimsft_8-1727431339810.png

 

Best Regards,
Yulia Xu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-xuxinyi-msft
Community Support
Community Support

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:

vxuxinyimsft_0-1727431048024.png

 

vxuxinyimsft_1-1727431065476.png

 

vxuxinyimsft_2-1727431085106.png

 

Measure:

 

 

Measure = SWITCH(TRUE(),
SELECTEDVALUE(Slicer[Category]) = "A", SUM('A Table'[Value]), 
SELECTEDVALUE(Slicer[Category]) = "B", SUM('B Table'[Value])
)

 

 

 

Output:

 

1. no relationships

vxuxinyimsft_3-1727431235538.png

 

vxuxinyimsft_4-1727431253345.png

 

vxuxinyimsft_5-1727431264296.png

 

2. have relationships

vxuxinyimsft_6-1727431305811.png

 

vxuxinyimsft_7-1727431328558.png

 

vxuxinyimsft_8-1727431339810.png

 

Best Regards,
Yulia Xu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Tahreem24
Super User
Super User

@HugoREGIS It would be good if you can share the sample dummy data. So will try out at my end.

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
FlipFlop1
Advocate I
Advocate I

Try:


Measure =
VAR Type = SELECTEDVALUE('Table correspondance CRC'[Type])
RETURN

SWITCH(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é"
)
rajendraongole1
Super User
Super 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!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.