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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
TaroGulati
Helper II
Helper II

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...

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

@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
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.