Forum Discussion

freginier's avatar
freginier
Solution Sage
4 years ago
Solved

Replace 0 with string

Hi all, 

 

How can I replace 0 with string value in a bar chart ?

I create a measure to display "Error" when average = 0 but only work in a table 

 

 

 

 

 

 

Measure = 
var AVG = 
AVERAGEX( 
    SUMMARIZE(
        table;table[name];
        "@avg_by_name";
        AVERAGE(
            table[amount]
        )
    ); 
[@avg_by_name]
)
return
if ( AVG = 0; "Error"; AVG ) 

 

 

 

 

 

 

Thank you

  • This work for me in table not in bar chart even if you add measure with tabular editor. Hope it will help

     

    Measure = 
    var AVG = 
    AVERAGEX( 
        SUMMARIZE(
            table;table[name];
            "@avg_by_name";
            AVERAGE(
                table[amount]
            )
        ); 
    [@avg_by_name]
    )
    return
    if ( AVG = 0; "Error"; AVG ) 

     

     

5 Replies

    • freginier's avatar
      freginier
      Solution Sage

      amitchandak it's functional error not a real error.

      I would like a bar chart with average measure (display the average) and when the average it's zero then replace 0 with "error" or "N/A"

      Do you think it's possible ?  

       

      I tried your link but unfortunately that doesn't work for me.. 

  • v-xiaotang's avatar
    v-xiaotang
    Community Support

    Hi freginier 

    Actually, that's not supported in bar chart, 

     

    Best Regards,

    Community Support Team _Tang

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

  • This work for me in table not in bar chart even if you add measure with tabular editor. Hope it will help

     

    Measure = 
    var AVG = 
    AVERAGEX( 
        SUMMARIZE(
            table;table[name];
            "@avg_by_name";
            AVERAGE(
                table[amount]
            )
        ); 
    [@avg_by_name]
    )
    return
    if ( AVG = 0; "Error"; AVG )