Help

How to express Switch()

Topic Labels: Formulas
1841 3
cancel
Showing results for 
Search instead for 
Did you mean: 
bima_sakti
4 - Data Explorer
4 - Data Explorer

Sorry I dont understand formula. Iam using 2 row for my stock, first row is (Stock-DO), Second is IF({Stock}<0,‘ :x: ’,IF({Stok}=0,‘ :heavy_minus_sign: ’,{Stock}))
I DO belive there is a better solution.
So how to express Switch((Stock-DO),Stock<0,‘ :x: ’,Stock=0,‘ :heavy_minus_sign: ’,Stock>0,‘Stock’)

3 Replies 3

This is actually a case where a nested IF() is more suited than SWITCH(). SWITCH statements compare definite answers so Stock < 0 would be evaluated to either true or false, so unless the output of {StockDO} is a true/false field (like a checkbox), this setup will not work for you.

Your best bet is the formula you already have, probably, with (presumed) typos fixed.

IF({Stock}<0,":x:",IF({Stock}=0,":heavy_minus_sign:",{Stock}))

Hopefully you mean columns. Comparing rows with formulas is not possible unless the rows are linked together.

the goal can be achieved using binary logic, like
SWITCH(
({Stock}=0)-({Stock}<0)
,1,‘ :heavy_minus_sign: ’
,-1,‘ :x: ’
,0,{Stock}
)

but that’s more complex and not needed in that case,
while nested IF is simple and obvious.

bima_sakti
4 - Data Explorer
4 - Data Explorer

thanks for the answer i just wanna know is there alternative, instead making a lot unique column