Add Suffix depending on Condition

Skybluekid

Well-known Member
Joined
Apr 17, 2012
Messages
1,231
Office Version
  1. 365
Platform
  1. Windows
Hi

Is there a way to add a suffix depending on the number of characters in a column. in other words, I have a column that shows the size of the file. What I would like to do is show the size in K or M depending on the size. So if the file size is over 1MB, then it would show the file size as xx.xx M. If it is under then it will show it as a K value

Thanks in advance
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Thank you, but this is in Excel, I would like it to be a Column generated in Power Query.
 
Upvote 0
You can use something like:

Power Query:
=if [V]>1048576 then Number.ToText([V] / 1048576, "F2") & "MB" else Number.ToText([V] / 1024, "F2") & "KB"

where V is the name of your field (assumes it's in bytes)
 
Upvote 0
Solution

Forum statistics

Threads
1,223,360
Messages
6,171,630
Members
452,411
Latest member
sprichwort

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top