Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Friends,
How to use case when statement in Qliview.
Thanks & regards,
krish
Hi,
You can use nested If or Match function to achieve the CASE logic.
could you give me more clarity on this
with examples?
you can define case statement as below,
CASE expression
WHEN value_1 THEN result_1
WHEN value_2 THEN result_2
...
WHEN value_2 THEN result_n
ELSE result
END AS expression
Let me know where you want to use the case statement. Is it in Script or in UI?
It really depends on what you're doing and where. As an expression in a chart, or to establish a field, you could use one of these approaches:
if(Field='A','something',if(Field='B','something else',if(Field='C','and another thing')))
pick(match(Field,'A','B','C'),'something','something else','and another thing')
Or you could add a field to your data model as a separate table:
Something:
LOAD * INLINE [
Field, Result
A, something
B, something else
C, and another thing
];
Or you could build a mapping table, and apply it in a subsequent load:
SomethingMap:
LOAD * INLINE [
Field, Result
A, something
B, something else
C, and another thing
];
applymap('SomethingMap',Field) as OtherField
Thanks Bro