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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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