vendredi 24 mai 2019

How to auto-convert a whole number into it's 2 decimals points?

Following the previous answers How to make a condition based on the number of decimals a number has with the IFS and AND functions in Google Sheets?

The formula given didn't return a result for whole numbers (any number without decimals, for example: 1(.00), 12(.00) etc.).

To make it return a result also for inputs with whole numbers, I thought of some formula like this:

=IF(A1=(a whole number/number without decimals),A1.00(A1 formatted as a whole number with two decimals),A1(A1 with any number of decimals>2 decimals).

How to make this formula

=ARRAYFORMULA(
 IF((LEN(IFERROR(REGEXEXTRACT(TO_TEXT(A1:A), "\.(.*)")))=4) * 
    (A1:A>B1:B) * (C1:C="Good"),     (A1:A-B1:B)*10000,
 IF((LEN(IFERROR(REGEXEXTRACT(TO_TEXT(A1:A), "\.(.*)")))=2) * 
    (A1:A>B1:B) * (C1:C="Great"),    (A1:A-B1:B)*100, )))

valid for whole numbers as well?

So that it returns a result for the whole number as well?

Aucun commentaire:

Enregistrer un commentaire