Forum Discussion

maurcoll's avatar
maurcoll
Icon for Helper IV rankHelper IV
11 months ago
Solved

help with text box including measures

Hi

 

I have the following measure which doesnt quite do what i need it to

Text Box = "In the last 12 months " & SELECTEDVALUE ([country]) & " is " &[change]& " with a difference of "& FORMAT([Change % - Date], "#,#%") & " compared to the previous 12 months"

 

I need to say if nothing is selected then All Countries but if one is selected then the selected value and also the format for the percentage is rounding i need it to be 2 decimal places 1.50% not 2% or -1.50% not -2%

 

Thank you

  • maurcoll Try the following:

    Text Box = 
    VAR _Country = IF( HASONEVALUE( 'Table'[country] ), SELECTEDVALUE( [country] ), "All countries" )
    VAR _IsAre = IF( HASONEVALUE( 'Table'[country] ), "is", "are" )
    VAR _Format = "0.00%;-0.00%;0.00%"
    VAR _Return = "In the last 12 months " & _Country & _IsAre &[change]& " with a difference of "& FORMAT([Change % - Date], _Format) & " compared to the previous 12 months"
    RETURN _Return
    

2 Replies

  • maurcoll Try the following:

    Text Box = 
    VAR _Country = IF( HASONEVALUE( 'Table'[country] ), SELECTEDVALUE( [country] ), "All countries" )
    VAR _IsAre = IF( HASONEVALUE( 'Table'[country] ), "is", "are" )
    VAR _Format = "0.00%;-0.00%;0.00%"
    VAR _Return = "In the last 12 months " & _Country & _IsAre &[change]& " with a difference of "& FORMAT([Change % - Date], _Format) & " compared to the previous 12 months"
    RETURN _Return