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
Anonymous
Not applicable

Column with different types of Data

Hello

 

I have a table with different data types in a column.

 

Measure Unit     Value

%10
Days11
'000 USD12
MT13
$ / MT14
# incidents15
Hours16
'000 LC17
000 USD18
'000 $19
%20
Days21
'000 USD22
MT23
$ / MT24
# incidents25
Hours26
'000 LC27
000 USD28
'000 $29
%30
Days31
'000 USD32
MT33
$ / MT34
# incidents35
Hours36
'000 LC37
000 USD38
'000 $39

 

I was thinking in create a new column with the formatted values.
For values with "%", FORMAT solved my problem.

 

Formatted Value = IF(Tab1[Measure Unit]="%";FORMAT(Tab1[Valor];"Percent");FORMAT(Tab1[Valor];"Standard"))

 

But I can't see a solution for others. I tried "Standard"*1000 for the '000 and 000 Measure Units, but didn't work.

 

Suggestions?

 

Thanks in advance

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Anonymous ,

 

Try the following code:

 

 

Format =
SWITCH (
    Table1[Measure];
    "%"; FORMAT ( Table1[Value] / 100; "Percent" );
    "000 USD"; FORMAT ( Table1[Value] * 1000; "Currency" )
    //Insert additional formats here 
    FORMAT(Table1[Value];"Standard")
)

 

 

Depending on your currency you may need to adjust for this for example:

 

Format =
SWITCH (
    Table1[Measure];
    "%"; FORMAT ( Table1[Value] / 100; "Percent" );
    "000 USD"; FORMAT ( Table1[Value] * 1000; "$0.000" );
    //Insert additional formats here 
    FORMAT(Table1[Value];"Standard")
)

Just keep adding your columns for each type of format.

 

Insert two lines for each format on the line where is the comment //

Should be as is below.

"%"; FORMAT ( Table1[Value] / 100; "Percent" );
    "000 USD"; FORMAT ( Table1[Value] * 1000; "$0.000" );

Regards,

MFelix

 

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

1 REPLY 1
MFelix
Super User
Super User

Hi @Anonymous ,

 

Try the following code:

 

 

Format =
SWITCH (
    Table1[Measure];
    "%"; FORMAT ( Table1[Value] / 100; "Percent" );
    "000 USD"; FORMAT ( Table1[Value] * 1000; "Currency" )
    //Insert additional formats here 
    FORMAT(Table1[Value];"Standard")
)

 

 

Depending on your currency you may need to adjust for this for example:

 

Format =
SWITCH (
    Table1[Measure];
    "%"; FORMAT ( Table1[Value] / 100; "Percent" );
    "000 USD"; FORMAT ( Table1[Value] * 1000; "$0.000" );
    //Insert additional formats here 
    FORMAT(Table1[Value];"Standard")
)

Just keep adding your columns for each type of format.

 

Insert two lines for each format on the line where is the comment //

Should be as is below.

"%"; FORMAT ( Table1[Value] / 100; "Percent" );
    "000 USD"; FORMAT ( Table1[Value] * 1000; "$0.000" );

Regards,

MFelix

 

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



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.