.xlsx formula - ret...
 

MegaSack DRAW - This year's winner is user - rgwb
We will be in touch

[Closed] .xlsx formula - return "Negative", "none" or "positive" during varianc

5 Posts
4 Users
0 Reactions
45 Views
 benz
Posts: 1143
Free Member
Topic starter
 

Stock count....

What formula could I use to identify whether a number in a column is -, 0 or +?

Thinking = if(a1<0,"Negative", "Positive") but how can I introduce into the same formula if a1=0, "No variance")?

Thanks!


 
Posted : 22/02/2017 12:41 pm
Posts: 0
Full Member
 

A nested IF will do it.

= IF(A1<0,"Negative",IF(A1>0,"Positive","No variance"))

Or, a trick that may or may not be useful, is to do a custom number format so that it [i]displays[/i] Negative/Positive/No variance but the value is still in the cell for other formulas to reference. Custom number format like so:

[<0]"Negative";[>0]"Positive";"No Variance"

In both cases be aware of Excel's tendency to introduce tiny rounding errors into complex sums, meaning sometimes what should be a zero is actually very slightly adrift (around E-15) and doesn't get treated as a zero.


 
Posted : 22/02/2017 12:52 pm
Posts: 0
Free Member
 

if(a1<0,"Negative",if(a1=0,"no variance","Positive"))

The question though is why you would want to (given text is good for almost nothing). Assuming it's for ease of reading why not just conditional format the cells to colour code or something?


 
Posted : 22/02/2017 12:54 pm
Posts: 36
Free Member
 

Use the SIGN function.

The Microsoft Excel SIGN function* returns the sign of a number. If the number is positive, the SIGN function will return 1. If the number is negative, the SIGN function will return -1. If the number is 0, the SIGN function will return 0.

* also exists in Google Sheets


 
Posted : 22/02/2017 12:57 pm
Posts: 0
Free Member
 

Stoner's answer might be perfect depending on the why...


 
Posted : 22/02/2017 12:59 pm
Posts: 0
Full Member
 

Or using the SIGN suggestion and avoiding IFs:

=CHOOSE(SIGN(A1)+2,"Negative","No Variance","Positive")

Or an alternative to SIGN:

=CHOOSE(IFERROR(ABS(A1)/A1,0)+2,"Negative","No Variance","Positive")

(lunchtime, I'm killing time....)


 
Posted : 22/02/2017 1:14 pm