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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
adnankabina
Helper II
Helper II

FORMAT NUMBERS in same field

I have this table two fields 

unit       qty

each      3.00

each      2.00

kg        0.450

kg        0.030

 

I want to format qty without deceimal for each unit and 2 decimal with kg as below

 

unit       qty

each      3

each      2

kg        0.450

kg        0.030

 

 

 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@adnankabina , You have use format Function that will make it text meausre Assume Qty is meausre of use sum(Table[Qty])

 

Switch(True() ,

Max(Table[Unit]) = "Unit", format([Qty], "#,###") ,

format([Qty], "#,###,000")

)

View solution in original post

v-stephen-msft
Community Support
Community Support

Hi @adnankabina ,

 

For your requirement, you need to convert the data type as text type.

You can create the following calculated column.

expected = SWITCH([unit],"each",FORMAT([qty],"#,###"),"kg",FORMAT([qty],"#,##0.000"))

8.png

As you can see, the calculated column is text type. If you want to use this field in a new calculated column or measure, you can use the VALUE function or use the original qty column.

 

 

 

Best Regards,

Stephen Tao

 

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

3 REPLIES 3
v-stephen-msft
Community Support
Community Support

Hi @adnankabina ,

 

For your requirement, you need to convert the data type as text type.

You can create the following calculated column.

expected = SWITCH([unit],"each",FORMAT([qty],"#,###"),"kg",FORMAT([qty],"#,##0.000"))

8.png

As you can see, the calculated column is text type. If you want to use this field in a new calculated column or measure, you can use the VALUE function or use the original qty column.

 

 

 

Best Regards,

Stephen Tao

 

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

Thank you guys. 🙂

amitchandak
Super User
Super User

@adnankabina , You have use format Function that will make it text meausre Assume Qty is meausre of use sum(Table[Qty])

 

Switch(True() ,

Max(Table[Unit]) = "Unit", format([Qty], "#,###") ,

format([Qty], "#,###,000")

)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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