Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Is there a CASE function, or something similar to it in Qlikview? I use the CASE function in Salesforce and it's useful
Definition: Checks a given expression against a series of values. If the expression is equal to a value, returns the corresponding result. If it is not equal to any values, it returns theelse_result
Use: CASE(expression,value1, result1, value2, result2,..., else_result) and replace expression with the field or value you want compared to each specified value. Replace each value and result with the value that must be equivalent to return the result entry. Replace else_result with the value you want returned when the expression does not equal any values.
There is no case statement in Qlikview. You can mutiple Ifs
If(expression=value1, result1,If(expression=value2, result2,else_result))
Use something like
pick(1+match(FIELD,'Value1','Value2')
, 'Default'
, 'Result1'
, 'Result2'
)
Hi,
You can use PICK() and MATCH() function
HTH
Sushil
I had thought about this, but wasn't sure if it was a bit messy.
Can you use it in conjunction with the GetFieldsSelections function? It seems to product some funny results when I use a nested if
Yes.Can you post what you have tried?
=if(GetFieldSelections(Region)='EMEA'
,NUM(SUM({$<[Business area]={'EMEA broking'}>}[Global Revenue £(000)s]*1000),'£#,##0')
,
if(GetFieldSelections(Region)='APAC'
,NUM(SUM({$<[Business area]={'Asia pacific broking (excl china)'}>}[Global Revenue £(000)s]*1000),'£#,##0')
,
if(GetFieldSelections(Region)='Americas'
,NUM(SUM({$<[Business area]={'Americas broking'}>}[Global Revenue £(000)s]*1000),'£#,##0')
,NUM(SUM({$<[Business area]={'Total global broking trading'}>}[Global Revenue £(000)s]*1000),'£#,##0'))))
Try something like
pick(1+match(GetFieldSelections(Region),'EMEA','APAC','Americas')
,NUM(SUM({$<[Business area]={'Total global broking trading'}>}[Global Revenue £(000)s]*1000),'£#,##0'))))
,NUM(SUM({$<[Business area]={'EMEA broking'}>}[Global Revenue £(000)s]*1000),'£#,##0')
,NUM(SUM({$<[Business area]={'Asia pacific broking (excl china)'}>}[Global Revenue £(000)s]*1000),'£#,##0')
,NUM(SUM({$<[Business area]={'Americas broking'}>}[Global Revenue £(000)s]*1000),'£#,##0')
)
This would only work properly with one selected Region.
You can also use the SubStringCount() function for a better overview and easy of implementation.
See my example here:
It's worth revisiting this:
Now that we have Coalesce(), we can combine it with the standard If() function for a very flexible Case()-equivalent.
The key insight here is that the 'else' clause in an If() is optional, and if it's absent it returns Null().
As such, we can go:
Coalesce(
If(condition1, result1),
If(condition2, result2),
If(condition3, result3),
default)