Forum Discussion

adnankabina's avatar
adnankabina
Icon for Helper II rankHelper II
3 years ago
Solved

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

 

 

 

  • 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")

    )

  • Anonymous's avatar
    Anonymous
    3 years ago

    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"))

    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.           

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    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"))

    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.           

  • 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")

    )