TEXT Function with decimals

ldoodle

New Member
Joined
Mar 2, 2010
Messages
40
Office Version
  1. 365
Platform
  1. Windows
Hey,

I have this formula: =TEXT(CONVERT(G4,C4,"Gibyte"),"#,##0.00#######")&K$1

K$1 is either GB or TB

In one example the calculated value is: 640.00GB
In another example, using Tibyte instead, the calculated value is: 0.625TB

I need decimals in only some cases. But I'd prefer 640.00GB to be shown as 640GB, and 1.00TB to be shown as 1TB.

I can change the TEXT format to #,##0.######### but this results in 640.GB and 1.TB

So, how do I either make the . optional, or have 2 different TEXT formats: if all the decimals are 0, use something like #,###0 and if any decimal is not zero, use the current format - I know IF funciton, just not how to detect for 'all zero decimals'

Thanks
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
You can test if the value is equal to INT(value). If so, there are no decimals. Sadly there is still no simple option for an optional decimal point. I would also suggest that you update your profile to indicate which version(s) of Excel you are using.
 
Upvote 0
I'm not sure exactly what formula you ended up with but as I understand it, this structure might also do what you want?
Excel Formula:
=SUBSTITUTE(youroriginalformula,".00"&K$1,K$1)
 
Upvote 0
PS: I currently have Excel 365 but need to support at least 2016.
 
Upvote 0
I'm not sure exactly what formula you ended up with but as I understand it, this structure might also do what you want?
Excel Formula:
=SUBSTITUTE(youroriginalformula,".00"&K$1,K$1)

=TEXT(CONVERT($G4,$C4,"byte"),IF(CONVERT($G4,$C4,"byte")=INT(CONVERT($G4,$C4,"byte")),"#,##0","#,##0.00#################"))&I$1

But I will give your option a go also. Thanks
 
Upvote 0
Then for that same formula, this would be my shorter equivalent
=SUBSTITUTE(TEXT(CONVERT($G4,$C4,"byte"),"#,##0.00#################")&I$1,".00"&I$1,I$1)
 
Upvote 0
Solution

Forum statistics

Threads
1,224,835
Messages
6,181,245
Members
453,026
Latest member
cknader

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