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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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

Top Solution Authors
Top Kudoed Authors