Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

gonzaloyaguesun
New Contributor III

Acumulative bar chart based on filtered values (QlikSense)

Dear all,

Initially, I have a bar chart displaying the Sales (measure) per Country (dimension) in 2016 and the following two filters:

* Week: it contains number from 1 to 52 (referring the number of weeks of 2016).

* Period: it's a new field created in the data load editor. It can be equal to "Weekly" or "YTD".

Each of them can take only value at a time. Obviously, the data displayed by the bar chart changes every time we select a different week.

If Period is equal to "Weekly", I want to display the Sales per Country for the selected week. This works! Additionally, if Period is equal to "YTD", I would like to display the acumulative Sales (from first week to the selected week) per Country. Unfortunately, I'm having problems with the second part (Period equal to 'YTD').

Please find below the code for the measure of the bar chart typed up to the moment. I think the issue might be in the red highlighted part.

IF([Period] = 'YTD', RangeSum(above(Sum([Sales]),0,[Week])), Sum([Sales])

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

Best regards,

Gonzalo

3 Replies
omarbensalem
Esteemed Contributor

Re: Acumulative bar chart based on filtered values (QlikSense)

maybe:

IF([Period] = 'YTD', RangeSum(above(Sum([Sales]),0,Rowno())), Sum([Sales])

gonzaloyaguesun
New Contributor III

Re: Acumulative bar chart based on filtered values (QlikSense)

Dear Omar,

Thank you very much for your reply. Unfortunately, I does not work. If I use the code you provided me, it displays Sales, accumulated based on the Country (dimension of the bar chart) but not based on Week (added filter).

Best regards,

Gonzalo

omarbensalem
Esteemed Contributor

Re: Acumulative bar chart based on filtered values (QlikSense)

if u have a date field; you should create a measure YTD based on that date field:

please refer to this thread  which I tried to explain step by step how to create such time measures:

YTD, MTD issue