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

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.

Reply
Anonymous
Not applicable

Is that possible to use Switch to return two measures?

Hello everyone!

I’m new to PowerBi and I’m trying to create two buttons to control the exibition of one visual.

I’ve tryed creating the following measure, but when I use it in value field of visual, no data is showed.

 

DinamicMeasure = SWITCH(TRUE(),

                SELECTEDVALUE('Dinâmica'[Botão])="Qtd", [Total Autoconstrução] && [Total Vistoria Autoconstrução],

                SELECTEDVALUE('Dinâmica'[Botão])="%", [% Autoconstrução no Prazo] && [% Vistoria Autoconstrução no Prazo],

                [Total Autoconstrução] && [Total Vistoria Autoconstrução]

)

 

Is there any way to return two measures on the result of Switch?

The image below shows what I want to achieve using the DinamicMeasure in value field.

Thanks!

 

DSCintra_0-1627337279530.png

 

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

Combining two number measures with && likely just results in a boolean True.  You should be able to do that with two separate measures with a similar structure, and put them both in the values area of your visual.  Also note that SWITCH(TRUE() is not needed in this case (but it is good that you know how to use it for other scenarios).

 

DinamicMeasure1 = SWITCH(SELECTEDVALUE('Dinâmica'[Botão]),

                "Qtd", [Total Autoconstrução],

                "%", [% Autoconstrução no Prazo],

                [Total Autoconstrução]

)

 

DinamicMeasure2 = SWITCH(SELECTEDVALUE('Dinâmica'[Botão]),

                "Qtd", [Total Vistoria Autoconstrução],

                "%",[% Vistoria Autoconstrução no Prazo] ,

                [Total Vistoria Autoconstrução]

)

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

3 REPLIES 3
mahoneypat
Employee
Employee

Combining two number measures with && likely just results in a boolean True.  You should be able to do that with two separate measures with a similar structure, and put them both in the values area of your visual.  Also note that SWITCH(TRUE() is not needed in this case (but it is good that you know how to use it for other scenarios).

 

DinamicMeasure1 = SWITCH(SELECTEDVALUE('Dinâmica'[Botão]),

                "Qtd", [Total Autoconstrução],

                "%", [% Autoconstrução no Prazo],

                [Total Autoconstrução]

)

 

DinamicMeasure2 = SWITCH(SELECTEDVALUE('Dinâmica'[Botão]),

                "Qtd", [Total Vistoria Autoconstrução],

                "%",[% Vistoria Autoconstrução no Prazo] ,

                [Total Vistoria Autoconstrução]

)

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Hello @mahoneypat  I had the same problem. your approach helped me to return two measures.
I am using line chart and my slicer options look like this:
Measure A / Measure B
Measure C / Measure D
Measure E / Measure F

I want to show a legend, but I can't control  the names displayed dynamically.
I named the two switch measures "Measure 1" , "Measure 2" to indicate that the "Measure 1" is the one on the left side (e.g. Measure A) and "Measure 2" the one on the right (e.g. Measure B), but I would like to display the actual measure names.
Is there a way to controll the names in the legend dynamically?

Many thanks in advance.

Anonymous
Not applicable

Pat, thank you so much!

This was exactly what I want to do.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors