Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

Calculation group: Substraction not working with format from format string expression

Hey there!

I am creating a calculation item in tabular editor which is supposed to calculate the difference between two values:

VAR BASELINE_VALUE = CALCULATE ( SELECTEDMEASURE (), 'Version'[Version] = "V2" ) 
VAR VALUE_TO_COMPARE = CALCULATE ( SELECTEDMEASURE (), 'Version'[Version] = "V1" )
RETURN BASELINE_VALUE - VALUE_TO_COMPARE

With an Format String Expression:

SWITCH ( Numberformat[Numberformat Factor], 
1, "#,0.00\ €;-#,0.00\ €;#,0.00\ €",
1000, "#,0.00\ T€;-#,0.00\ T€;#,0.00\ T€",
1000000, "#,0.00\ M€;-#,0.00\ M€;#,0.00\ M€" )


For some reason the value does not get the "€", "T€", "M€". Can anybody help with that?


When using this instead it works:

VAR BASELINE_VALUE =
    CALCULATE ( SELECTEDMEASURE (), 'Version'[Version] = "V2" )
VAR VALUE_TO_COMPARE =
    CALCULATE ( SELECTEDMEASURE (), 'Version'[Version] = "V1" )
RETURN FORMAT ( ( BASELINE_VALUE - VALUE_TO_COMPARE ),
        SWITCH (
            Numberformat[Numberformat Factor],
            1, "#,0.00\ €;-#,0.00\ €;#,0.00\ €",
            1000, "#,0.00\ T€;-#,0.00\ T€;#,0.00\ T€",
            1000000, "#,0.00\ M€;-#,0.00\ M€;#,0.00\ M€" ) )

 
In my measure I have the Sum / Numberformat Factor.

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous 

    I have a test on your sample, I think the second code will work well. Format your measure after calculation.

    My easy sample:

    Here is a blog about calculate group in tabular.

    For reference: Introducing Calculation Groups

    If this reply still couldn't help you solve your problem, please share a sample with us and show us a screenshot with the result you want.

     

    Best Regards,
    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.