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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
TaroGulati
Helper III
Helper III

FORMAT Function error

Hi guys,

 

I am having difficulty in using the format function.

 

I have this simple table:

 

TaroGulati_0-1646649354821.png

I am using the simple column chart to represent value based on the slicer selection. 

 

TaroGulati_1-1646649406833.png

This is the measure that i am using:

 

Value = SWITCH(SELECTEDVALUE('Table'[DIM]),
"A",30,
"B",40,
"C",50,
"D",60)
 
my expected result is this, once i select A or B in the slicer it should show value as a whole number but once i select C or D i want it to show as percentage. i tried using Format but it is converting in text & visual is breaking.
 TaroGulati_2-1646649573174.png
TaroGulati_3-1646649670791.png

 

 

any suggestion would be really helpful. 

 

Thanks

 

 

1 ACCEPTED SOLUTION
mwegener
Most Valuable Professional
Most Valuable Professional

@TaroGulati 

Please mark my post as solution, this will also help others.
Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


View solution in original post

9 REPLIES 9
Tahreem24
Super User
Super User

@TaroGulati Try this but it will return as text because it has different return types like whole number and percentage value.

 
Column = SWITCH(TableName[DIM],
"A",Format(30,"##"),
"B",FORMAT(40,"##"),
"C",FORMAT(0.5,"Percent"),
"D",FORMAT(0.6,"Percent")
)
Capture.JPG
 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

@Tahreem24 thanks for the suggestion. For table is not an issue. I am trying to represnt these values on line chart which doesn't support the text format of measure. 

 

 

amitchandak
Super User
Super User

@TaroGulati , Format the first 2 also, This creates few options as numbers and few as %, that will not work

 

You can explore calculation group if you need a different format for measure slicer

 

tabular - Calculation groups
https://docs.microsoft.com/en-us/analysis-services/tabular-models/calculation-groups?view=asallprodu...

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak  thanks for the suggestion. i believe with the help of calculation group, this would not work because that will also return a measure as text and graph doesn't accept the format text. 

 

mwegener
Most Valuable Professional
Most Valuable Professional

Hi @TaroGulati ,

 

Amit is right, take a look at the attached PBIX.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


@mwegener thanks for your suggestion. 

 

I think problem is still there. 

 

in your calculation item, you assigned values to each selection of slicer but it is still not showing the values in percentage with % sign on the axis. 

 

i tried to modifiy but still doesn't give the desired result. 

 

Thanks again for your efforts. 

 

mwegener
Most Valuable Professional
Most Valuable Professional

Hi @TaroGulati ,

 

for me, the axis changes depending on the selection.

Is your requirement different?

2Format.gif

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


@mwegener thank you very much.

 

it seems my power bi desktop is not updated with Feburary 2022 features. Last version is of Dec 2021. I guess for this reason i don't see the same results that you see. 

 

TaroGulati_0-1646667851138.png

Thank you again.

mwegener
Most Valuable Professional
Most Valuable Professional

@TaroGulati 

Please mark my post as solution, this will also help others.
Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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