cancel
Showing results for 
Search instead for 
Did you mean: 
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
Microsoft

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
Microsoft

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


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
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors
Top Kudoed Authors