Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
New to Qlik and have a question on storing the outputs of an if statement to a custom dimension to be used in charts.
Basically, what I want to do is something like this:
if([date] > Today, 'Future', 'Past')
Then be able to say if [CustomDimension] = 'Future', do something (count the number of records returned, custom coloring, etc)
How do I save the if statements value to a custom dimension to use elsewhere without having to reuse the if statement?
You would typically add this as a field in your load script, making it easily reusable across the entire app.
I did the following:
SET _DateCheck = if([date] > Today, 'Future', 'Past');
And then I set a pie chart to _DateCheck and did the measure as a Count([ID]).
Now, I want to do a custom color on the pie chart like this:
Custom Color Expression: If(_DateCheck = 'Future', Blue(), Red())
but it is changing the entire pie chart to Red()
I have also tried
If(Pick(_DateCheck , 'Future'), Blue(), Red()) but it still colors the entire pie chart red instead of just the past slice.
Set creates a variable, not a field, and it does not evaluate the expression (you would need Let for that). You also incorrectly used Today instead of Today().
You would typically do this as a field in the load statement, e.g.
Load Date, if(Date > Today(), 'Future','Past') as isFuture, SomeOtherField
From SomeTable;