Forum Discussion

kkalyanrr's avatar
kkalyanrr
Helper V
7 years ago
Solved

Creating a dynamic chart(with formats Number and Percentage)

Hello,

 

I'm trying to creat a dynamic chart(Stacked Bar Chart)  which can display a metric in both number and percentage formats..

I tried creating a switch measure with appropriate formulae but the problem is it is showing both in same decimal format.

 

Please help me in getting the actual result.

 

 

  • Hi kkalyanrr,

     

    It is not supported to make a measure to dynamically return different data types for result. As you can in below screenshot, using FORMAT function to format result converts the data type to Text which resulted in the blank chart.

     

    Best regards,

    Yuliana Gu

7 Replies

  • itsmebvk's avatar
    itsmebvk
    Continued Contributor

    kkalyanrr try two things 

     

    1) Check these properties

     

    Visualizations -> Format tab- > Go to Field Formatting-> There is a parameter 'Value decimal places

     

    OR

     

    2) Create follwing measure or column using Format Fixed (replace with your columns)

     

    Swith = SWITCH(TRUE(),Report[Column]=1,FORMAT([Measure],"Fixed"),Report[Column]=2,FORMAT([Measure2],"Fixed"))

     

    • kkalyanrr's avatar
      kkalyanrr
      Helper V

      itsmebvk

       

      I've tried both the options but couldnt get the exact result..

       

      The result I was looking for, when I use "Number" in slicer selection the chartr shld display number values(like 12,14) and "Percentage" in slicer selection the chart should display Percentage values(like 20%,30%)

       

      Thanks..

      • itsmebvk's avatar
        itsmebvk
        Continued Contributor

        kkalyanrr I am able to switch measure and format it using following formula

         

        Swith = SWITCH(TRUE(),Report[Column]="Number",FORMAT([Number],0),Report[Column]="Percentage",FORMAT([Percentage],"Percent")
  • v-yulgu-msft's avatar
    v-yulgu-msft
    Microsoft Employee

    Hi kkalyanrr,

     

    It is not supported to make a measure to dynamically return different data types for result. As you can in below screenshot, using FORMAT function to format result converts the data type to Text which resulted in the blank chart.

     

    Best regards,

    Yuliana Gu

  • Relative newbie to Power BI but is there a solution to this problem. I am currently using a measure, see below, to return either a percentage or a whole number to a set of line and bar charts, depending on a slicer selection. 

     

    When I add the FORMAT function my charts vanish. 

    If it has been resolved can you give me a link to the answer. If not is there any word as to when it may be resolved?

     

    MetricMeasure = IF(LEFT(SELECTEDVALUE('Metric'[Metric], "All"),6) = "Share ", [Total_Summary], IF(SELECTEDVALUE('Metric'[Metric],"All")="Expenditure", SUM([Expenditure]), IF(SELECTEDVALUE('Metric'[Metric],"All")="Products", SUM([NoProducts]), SUM([Value]))))