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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Switch measure value with 2 selection

I have a switch measure with below formula :

 measure = SWITCH ( SELECTEDVALUE(Column1)),"Category1",[Measure1],"Category2",[Measure2],"Category3",[Measure3]...))

Now when i select Category1 and Category2 in Slicer, the measure is blank, i know switch only works on 1 selection. Is there any alternate way to achieve this?

 

3 ACCEPTED SOLUTIONS
Ritaf1983
Super User
Super User

Hi @Anonymous 

If I understand you correctly, you need
SWITCH with multiple conditions.

In the following link, you will find an explanation and example that may be helpful:
https://exceltown.com/en/tutorials/power-bi/powerbi-com-and-power-bi-desktop/dax-query-language-for-power-bi-and-power-pivot/switch/

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

Mahesh0016
Super User
Super User

EMP
Advocate III
Advocate III

I just tried this and it's working for me:

 

IF(AND(SELECTEDVALUE('Table1'[Column1]) = "whatever", SELECTEDVALUE('Table2'[Column2]) = "2nd whatever"), "Bring me this",

IF(AND(SELECTEDVALUE('Table1'[Column1]) = "otherwhatever", SELECTEDVALUE('Table2'[Column2]) = "2nd otherwhatever"), "Bring me this other thing"))

 

Seemingly you can nest it as far as you want, I'm at 2 criteria, 2 selections each for a possible combination of 4. I don't know if that's the best way to do this but I haven't been able to find any other suggestions and it is working <shrug>

 

View solution in original post

4 REPLIES 4
Jhophshepht
Frequent Visitor

Hola, creo que tengo una duda similar al primer comentario, en mi caso en el cuadro que se muestra por defecto quiero mostrar más de un dato de una misma columna, me explico, tengo un gráfico de barras que muestra los días en que se realizó un inventario, en el popup se muestran varios datos que agregue, pero hay uno que es el nombre del proveedor y son varios por día, cuando agrego la columna al tooltip solo me muestra el primero o el último, se pueden mostrar todos? 

asi es como sale ahora, la segunda fila categoria, la tengo en otra tabla, 

Jhophshepht_0-1713968297350.png

 

si lo hago con la misma tabla, me sale solo un nombre, el primero o el ultimo

Jhophshepht_1-1713968297603.png

 

la idea es que salgan todos estos.

COLISEO CV TRADING
COMERCIAL MARSHALL Y SALAS SPA
MODULBOX SPA
NUTRISCO CHILE S A
SOCIEDAD PUNTA DE LOBOS SA
TAMY SPA
TECNOPAPEL S A

y despues de poder hacer eso, poder poner un switch de condicion, para que muestre otra columna en el caso de otra condicion.

 

La otra opcion que tambien me sirve es agregar una hoja nueva con la informacion como un tooltip, la estuve creando pero puedo mostrar la informacion que necesito, pero ademas necesito usar un switch supongo para cambiar la informacion. 

este es para un almacen.

Jhophshepht_2-1713976093113.png

este es para otro 

Jhophshepht_3-1713976125896.png

en ambos almacenes cuando hay mas de una categoria al dia. no muestra informacion

Jhophshepht_4-1713976191750.png

encontre esta formula : 

Categorias =
VAR slicerValue = SELECTEDVALUE(Afta[whsA])
RETURN
    SWITCH(
        TRUE,
        slicerValue = "Merkadis",
            [CatM],
        TRUE,  
            VALUE([CatP])
    )
 
que usa estas dos.
 
CatM = SELECTEDVALUE(Afta[Proveedor])
CatP = SELECTEDVALUE(Afta[Peso])
 
en escencia lo que necesito es mostrar para "Merkadis" la columna proveedor con todos sus registros y para "Purina" la columna peso con todos sus registros.
EMP
Advocate III
Advocate III

I just tried this and it's working for me:

 

IF(AND(SELECTEDVALUE('Table1'[Column1]) = "whatever", SELECTEDVALUE('Table2'[Column2]) = "2nd whatever"), "Bring me this",

IF(AND(SELECTEDVALUE('Table1'[Column1]) = "otherwhatever", SELECTEDVALUE('Table2'[Column2]) = "2nd otherwhatever"), "Bring me this other thing"))

 

Seemingly you can nest it as far as you want, I'm at 2 criteria, 2 selections each for a possible combination of 4. I don't know if that's the best way to do this but I haven't been able to find any other suggestions and it is working <shrug>

 

Mahesh0016
Super User
Super User

@Anonymous 

Mahesh0016_0-1682746046267.png

Mahesh0016_1-1682746215730.pngMahesh0016_2-1682746236801.pngMahesh0016_3-1682746256406.pngMahesh0016_4-1682746278662.png

 

Ritaf1983
Super User
Super User

Hi @Anonymous 

If I understand you correctly, you need
SWITCH with multiple conditions.

In the following link, you will find an explanation and example that may be helpful:
https://exceltown.com/en/tutorials/power-bi/powerbi-com-and-power-bi-desktop/dax-query-language-for-power-bi-and-power-pivot/switch/

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.