Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Conditional expressions within bar charts

Good morning,

     I am attempting to generate a bar chart that compares Actual results to Budget results over a 12 month period. So my dimension is Month. The bars for each month should look different depending on whether Actuals exceeded budget or not.  I have created 2 sets of expressions to be used, depending on the results, but when I apply conditions, the condition is calculated for the total 12 months, not by month.

Is what I am attempting possible?

I have attempted a lot of variations on conditional formulas, the simplest being the below, assigned to separate expressions:

sum(BTOT) < sum(ATOT)

and

sum(BTOT) > sum(ATOT)

When I try this, the second condition is always true (since it's comparing 5 months of actuals and 12 months of budget), how can I get it to recognize that for Jan, Feb and May the first condition is true and the rest of the year the second is true?

1 Solution

Accepted Solutions
jerem1234
Specialist II
Specialist II

So you are using the Conditional Expression that is above you main expression? That won't work with what you are trying to do, it's an all or nothing deal. Either the chart uses that expression or it doesn't. The chart won't filter and choose what expression to use for each value in your dimension. You'll have to move the conditional into your actual expression (Combine your two expression into one) like:

if(sum(BTOT) < sum(ATOT), Expression1, Expression2)

so as an example:

if(sum(BTOT) < sum(ATOT), sum(BTOT), sum(ATOT))

Hope this helps!

View solution in original post

3 Replies
Not applicable
Author

Bueller?

jerem1234
Specialist II
Specialist II

So you are using the Conditional Expression that is above you main expression? That won't work with what you are trying to do, it's an all or nothing deal. Either the chart uses that expression or it doesn't. The chart won't filter and choose what expression to use for each value in your dimension. You'll have to move the conditional into your actual expression (Combine your two expression into one) like:

if(sum(BTOT) < sum(ATOT), Expression1, Expression2)

so as an example:

if(sum(BTOT) < sum(ATOT), sum(BTOT), sum(ATOT))

Hope this helps!

Not applicable
Author

I was using that expression as the condition on my expressions.  Incorporating them into an If statement worked perfectly.  Nice, simple solution.  Thank you so much!