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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
kkalyanrr
Helper V
Helper V

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 Capture.JPGgetting the actual result.

 

 

1 ACCEPTED SOLUTION
v-yulgu-msft
Microsoft Employee
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.

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
LyellDuggan
New Member

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]))))
v-yulgu-msft
Microsoft Employee
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.

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
itsmebvk
Continued Contributor
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"))

 

@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
Continued Contributor
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")

@itsmebvk

Its working fine for Card chart but not with the  Bar Charts..Please see the attached screenshot.


Capture1.JPG

itsmebvk
Continued Contributor
Continued Contributor

@kkalyanrr Apparently I am also observing same issue, I had gone through few threads, they also facing same issue, seems to be limitations in PBI as far as my understanding.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.