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
Saxon10
Post Prodigy
Post Prodigy

Convert units

 

Hi,

 

Column A:C are length, width and Height and column D is unit of dimension of each rows, column D contain multiple unit of dimension which is CM, MM and M.

 

How can I convert CM and MM into M based on the unit of dimesion column D? In Excel I am apply the convert function but the same function in BI completly is difference. 

 

I would like to achieve my desired result by using new calculate column.

 

Can you please advise. 

 

Rules:

 

1.If column D is CM and MM then convert as Meter (M) from E:G

 

2.If column D is M then return as same from E:G

 

3.If column D is Blank and Length, Width and Height is 0 then return the same thing from E:G

 

DataResult in Meter (M)
LengthWidthHeightUOM DimensionLength in MWidth in MHeight in M
102030CM0.10.20.3
657146CM0.650.710.46
100200300MM123
550110870MM5.51.18.7
12814.5M12814.5
184.818.5M184.818.5
000 000
000 000
000 000

 

Capture1.PNG

 

 

 

 

1 ACCEPTED SOLUTION
selimovd
Super User
Super User

Hey @Saxon10 ,

 

for each of the 3 columns (Lenght, Width and Height) add a calculated column:

Length in Meter =
SWITCH(
    MyTable[UOM Dimension],
    "M", MyTable[Length],
    "CM", MyTable[Length] / 100,
    "MM", MyTable[Length] / 1000
)

 

Same formula for the other 2 measures 😉 

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

View solution in original post

6 REPLIES 6
selimovd
Super User
Super User

Hey @Saxon10 ,

 

for each of the 3 columns (Lenght, Width and Height) add a calculated column:

Length in Meter =
SWITCH(
    MyTable[UOM Dimension],
    "M", MyTable[Length],
    "CM", MyTable[Length] / 100,
    "MM", MyTable[Length] / 1000
)

 

Same formula for the other 2 measures 😉 

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

Thanks for your qucik reply. I am receving error here Exprssions that yield variant data-type cannot be used to define calulated column. 

 

Those three columns came from as a calculate column and those three column are stored as a text so can you please help me.

 

Hey @Saxon10 ,

 

can you check if the [Length] column is from the format decimal number?

Is the column [UOM Dimension] from the format Text?

 

Can you post a screenshot?

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

Hi,

 

Thanks for your reply. Yes, you are right the length column is not number format that's the reason I got error. If I convert into number then everything is fine. 

Hi @Saxon10,

 

Try to create measures and apply @selimovd's formula.

 

Best Regards,

Link

Thanks for the your reply. Now the problem is fixed and approved the solution 

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.