- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Column with both Mib and Gib values, convert Mib to Gib
I have a column like this:
I would lik to convert MiB to GiB, so that everything is in GiB, i have no idea of how to achieve it nor how to search for this... all the info i've found this far is converting from Mib to Gib, but nothing about MiB AND GiB to one of both.
Any help would be much appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @mcflurry ,
For this need, I think there is a simpler way: use the replace value function in the power query, refer to the following test results:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtIzMFVwz3RSitWJVjLUszSHc4AyIE4SRMbMVM/SUMEXptDcUs/cBMKNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type","M","G",Replacer.ReplaceText,{"Column1"})
in
#"Replaced Value"
If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.
Best Regards,
Henry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @mcflurry ,
For this need, I think there is a simpler way: use the replace value function in the power query, refer to the following test results:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtIzMFVwz3RSitWJVjLUszSHc4AyIE4SRMbMVM/SUMEXptDcUs/cBMKNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type","M","G",Replacer.ReplaceText,{"Column1"})
in
#"Replaced Value"
If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.
Best Regards,
Henry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Ok, both codes are working... didn't worked because i had 2 blank rows in the column.
The problem now is that both codes display the same value in every row, like this:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Did you create a measure or a column?
My code was for a column.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

I'm assuming here that your column is a text field e.g. "2.05 GiB" is stored as a text value.
GiB =
VAR __Datatype = RIGHT( 'Table'[Reclaimable Space] , 3)
VAR __Length = LEN( 'Table'[Reclaimable Space] )
VAR __Value = VALUE( LEFT( 'Table'[Reclaimable Space] , __Length - 4) ) -- Return numeric value
RETURN
SWITCH( TRUE(),
__Datatype = "MiB", (__Value / 1024), -- Convert MiB value to GiB
__Datatype = "GiB", __Value -- Return GiB value
)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Yep, it's text value.
I've tried your code and it returns this error:
An argument of function 'LEFT' has the wrong data type or has an invalid value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Open Power Query (Transform Data) and check that the column Reclaimable space is stored as text, i.e. the data type should be displayed as "ABC" and not "ABC 123". The latter would imply the column has not been explicitly formatted as text. One you have changed type to Text (if needed) close and apply. Then try the formula I previously shared. It works for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

It's stored as Text.
But it isn't working yet.
An argument of function 'LEFT' has the wrong data type or has an invalid value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Or try this (once you're sure the column is stored as text)
GiB =
VAR __Datatype = RIGHT( 'Table'[Reclaimable Space] , 3)
VAR __Length = LEN( 'Table'[Reclaimable Space] )
VAR __Value = VALUE( LEFT( 'Table'[Reclaimable Space] , __Length - 4) ) -- Return numeric value
RETURN
SWITCH( TRUE(),
__Datatype = "MiB", (__Value / 1024), -- Convert MiB value to GiB
__Datatype = "GiB", __Value, -- Return GiB value
0
)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Yep, working, but it displays the same result for every cell:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Same result:
An argument of function 'LEFT' has the wrong data type or has an invalid value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

How about this (wrapped in an IFERROR)
GiB =
VAR __Datatype = RIGHT( 'Table'[Reclaimable Space] , 3)
VAR __Length = LEN( 'Table'[Reclaimable Space] )
VAR __Value = VALUE( LEFT( 'Table'[Reclaimable Space] , __Length - 4) ) -- Return numeric value
RETURN
IFERROR(
SWITCH( TRUE(),
__Datatype = "MiB", (__Value / 1024), -- Convert MiB value to GiB
__Datatype = "GiB", __Value, -- Return GiB value
0
) , 0)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

@mcflurry , Try this;
Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi, not working.
Cannot convert value '' of type Text to type Number.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

@mcflurry Nope syntax is not incorrect. I tested and then shared the code. As per the below screen shot I am not getting any kind of error.
Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Yep, working, but it displays the same result for every cell:

Helpful resources
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!
Power BI Monthly Update - February 2025
Check out the February 2025 Power BI update to learn about new features.

Subject | Author | Posted | |
---|---|---|---|
08-12-2024 10:10 PM | |||
12-04-2023 04:31 AM | |||
05-06-2024 04:34 AM | |||
07-27-2024 01:39 PM | |||
03-22-2024 06:48 AM |
User | Count |
---|---|
89 | |
77 | |
62 | |
47 | |
39 |
User | Count |
---|---|
118 | |
85 | |
81 | |
58 | |
39 |