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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
ale_BI
Helper I
Helper I

Why do my SWITCH measure results have a long number despite selecting 2 decimals?

ale_BI_3-1678957640453.png

 

 

To give a bit more info, this is the main part of how I insert the values into the SWITCH measure. Please note it's a very shortened version, but includes the two main types of values (with and without additional text)

 

var delta_etc_pfe_perc =

IF( LEN([Δ ETC vs PFE %]) > 0, [Δ ETC vs PFE %], 0 )

var result = SWITCH( TRUE(), /* Metric = Days */
    metrics = 1 && selected_column_1 = "Planned", [Frc Days],
    metrics = 1 && selected_column_1 = "Δ ETC vs PFE", [Δ ETC vs PFE] & " (" & delta_etc_pfe_perc & ")",

 

So in this case, my value Delta ETC vs PFE is numerical, but the variable I insert after is text because SWITCH doesn't allow me to insert numerical percentage variables, as they will become reformatted as non percentage. So I format as text the measure as I calculate it on its own as follows: FORMAT(Result, "0.00%") and then here make that if() call on it


As you can see I also added a measure to conditionally colour only some of the values, and I just want to state beforehand that changing that won't affect the result.

Why do my SWITCH measure results look like this? I already fixed the decimal number to 2 values. It only happens for those rows where I stated that it should give me both the result of an operation and then another one within parenthesis. But both of those values I also fixed to 2 decimals only


 

1 ACCEPTED SOLUTION
andhiii079845
Super User
Super User

Can you try something like:

var result = SWITCH( TRUE(), /* Metric = Days */
    metrics = 1 && selected_column_1 = "Planned", round([Frc Days],2),
    metrics = 1 && selected_column_1 = "Δ ETC vs PFE", round([Δ ETC vs PFE],2) & " (" & delta_etc_pfe_perc & ")",




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
andhiii079845
Super User
Super User

Can you try something like:

var result = SWITCH( TRUE(), /* Metric = Days */
    metrics = 1 && selected_column_1 = "Planned", round([Frc Days],2),
    metrics = 1 && selected_column_1 = "Δ ETC vs PFE", round([Δ ETC vs PFE],2) & " (" & delta_etc_pfe_perc & ")",




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




This got the job done precisely, thank you!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.