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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

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
Microsoft Employee
Microsoft 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
Microsoft Employee
Microsoft 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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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