3 Replies Latest reply: Mar 23, 2011 5:52 PM by justin_jag

# Stacking Two Expressions on the Same Bar in a Bar Graph

Hi QlikView Ninjas,

This seems like a pretty common scenario but I cannot seem to make it work in my graph. I have three data points Budget, Actuals and Forecast. On my bar graph I want to show Budget as it's own bar but Actuals and Forecast stacked together next to budget. Something like the image below. I tried two expressions, budget and forecast + actuals = gave me two bars but the second one wasn't stacked. I added an additional dimension but that didn't work either. Then I tried with three expressions but still can't get it to work. Any help would be greatly appreciated.

• ###### Stacking Two Expressions on the Same Bar in a Bar Graph

You can achieve it with data well structured.

Try to have a file like this

Create a field metric with only 2 values, create a field forecast where is null for metric = Budget

Then create a bar stack bar chart with Metric as dimension and 2 expressions Sum(Value) , Sum(Forecast)

 Mois Metric Value Forecast 1 Budget 100 0 1 Actual 70 20 2 Budget 200 0 2 Actual 200 50
• ###### Stacking Two Expressions on the Same Bar in a Bar Graph

Basically, your problem is that you are trying to combine a Group Chart and a Stacked Chart, and it doesn't work together. So, you need to trick QlikView into treating it as a Stacked chart - 2 Dimensions, 1 Expression.

To achieve your goal, you need to create a dummy table with 2 fields, associated with each other:

Dimension1 Dimension2

Budget Budget

Fcst/Actual Fcst

Fcst/Actual Actual

In the expression, you'll need to validate the value of Dimension2 and use the appropriate formula.

Now, the first Dimension will cause creating of 2 separate bars, and the 2 values of the Second Dimension will make he bars stacked.

good luck!

• ###### Stacking Two Expressions on the Same Bar in a Bar Graph

Thanks for the quick responses. You got me thinking about the problem from a different angle. Here is how I solved the problem:

I reformat the data:

 Council Type Budget Actual Forecast SAM Budget 1000 0 0 SAM Act+Forecast 0 200 800 EIS Budget 5000 0 0 EIS Act+Forecate 0 3000 1500

Then I created a chart using Council and Type as dimensions. I used three expressions, sum(Budget), only(Actual), only(Forecast). Apparently the "only" function filters just the values I wanted. Resulting in the chart below: