4 Replies Latest reply: Dec 12, 2017 3:56 PM by Gonzalo Yagüe Suñol

# Variable X scale on a combo chart (Qlik Sense)

Dear all,

On the one hand, I have a combo chart displaying Sales and Forecast (measures) for each Week (dimension). Week is an integer ranging from 1 to 40. Sales are visualised as a bar chart and Forecast as a line chart. On the other hand, I have a filter with the number of Weeks.

Firstly, I have to display Forecast  from 1st to 40th week regardless which week is selected on the filter. I have achieved it by typing the following code: Sum({1}Forecast). Secondly, I need to display Sales from the  first week to the maximum value selected on the filter. For example, if I selected either fourth and fith week or just fifth week, Sales should be displayed only for first, second, third, fourth and fifth week.

I would really appreciate if anyone could help me solve this issue. Thank you very much in advance.

Best regards,

Gonzalo

• ###### Re: Variable X scale on a combo chart (Qlik Sense)

Hi Gonzalo,

If first week means beginning of the year you may try this expression

=SUM({<Year={'\$(=max(Year))'},Date={'<=\$(=(max(Date)))'},Month=,Day=>} Sales)

Month=,Day= needed to ignore selections from such fields

you may simply remove it from expression

Would be nice if you provide feedback.

• ###### Re: Variable X scale on a combo chart (Qlik Sense)

Hi Max,

Thank you very much for your help. Unfortunately, Week does not come from a date field so we cannot work with years. It's just a number ranging from 1 to 40.

Just in case, I did not explain properly the issue... Let's imagine we had the following data:

Week      Sales

1             300

2             400

3             250

4             600

5             700

If we selected week on Week 3 on the filter. The combo chart should display the following Sales:

Week      Sales

1             300

2             400

3             250

Thank you very much.

Best regards,

Gonzalo

• ###### Re: Variable X scale on a combo chart (Qlik Sense)

Gonzalo,

=Sum({<Week={'>=1<=\$(=(Max(Week)))'}>} Sales)

• ###### Re: Variable X scale on a combo chart (Qlik Sense)

Hi Max,

The code is great but, instead of single quotes, double quotes were needed.

The final code is the following one:      =Sum({<Week={">=1<=\$(=(Max(Week)))"}>} Sales)

I really appreciate your help. Thank you very much.

Best regards,

Gonzalo