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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

DAX measure for Unit Conversion

Please I need help. I have a field named Size and example of information in it is (e.g 30 GB, 50 MB, 40 TB).   My goal is to create another column with DAX by converting all the values into GB. So if a value is 30 GB, no calculation will be done, if a value is 50 MB, the condition will divide the 50 by 1000, if a value is 40 TB, the condition will divide 40 by 0.001. 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Anonymous ,

Here are the steps you can follow:

1. Create calculated column.

DAX measure for Unit Conversion1 =
SWITCH(
TRUE(),
RIGHT('Table'[Size],2)="GB",VALUE( LEFT('Table'[Size],LEN([Size])-(SEARCH("GB",[Size])-1))),
RIGHT('Table'[Size],2)="MB",DIVIDE( VALUE( LEFT('Table'[Size],LEN([Size])-(SEARCH("MB",[Size])-1))),1000),
RIGHT('Table'[Size],2)="TB",VALUE( LEFT('Table'[Size],LEN([Size]) -(SEARCH("TB",[Size])-1)))/0.001)

2. Select [DAX measure for Unit Conversion1] – set the decimal point to 2.

vyangliumsft_0-1660729557073.png

3. Result:

vyangliumsft_1-1660729557075.png

 

Best Regards,

Liu Yang

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

Hi  @Anonymous ,

Here are the steps you can follow:

1. Create calculated column.

DAX measure for Unit Conversion1 =
SWITCH(
TRUE(),
RIGHT('Table'[Size],2)="GB",VALUE( LEFT('Table'[Size],LEN([Size])-(SEARCH("GB",[Size])-1))),
RIGHT('Table'[Size],2)="MB",DIVIDE( VALUE( LEFT('Table'[Size],LEN([Size])-(SEARCH("MB",[Size])-1))),1000),
RIGHT('Table'[Size],2)="TB",VALUE( LEFT('Table'[Size],LEN([Size]) -(SEARCH("TB",[Size])-1)))/0.001)

2. Select [DAX measure for Unit Conversion1] – set the decimal point to 2.

vyangliumsft_0-1660729557073.png

3. Result:

vyangliumsft_1-1660729557075.png

 

Best Regards,

Liu Yang

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

SpartaBI
Community Champion
Community Champion

@Anonymous 

 

 

Here is a link to download a sample solution file:
DAX measure for Unit Conversion 2022-08-10.pbix

GB Value = 
SWITCH(
    TRUE(),
    CONTAINSSTRING('Table'[Column1], "GB"), 'Table'[Column1],
    CONTAINSSTRING('Table'[Column1], "MB"), VALUE(LEFT('Table'[Column1], FIND(" ", 'Table'[Column1], 1) - 1 )) / 1000 & " MB",
    CONTAINSSTRING('Table'[Column1], "TB"), VALUE(LEFT('Table'[Column1], FIND(" ", 'Table'[Column1], 1) - 1 )) / 0.001 & " TB"
)

 

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Showcase Report – Contoso By SpartaBI

Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Anonymous
Not applicable

Oh wow, thank you so much. This really helps. But is there a way to make usre the units does not show again in the converted column?

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.