Qlik Community

QlikView Layout & Visualizations

Discussion Board for collaboration on QlikView Layout & Visualizations.

Announcements
Announcement: Certain actions are currently causing a Page Not Found error. This is a known issue and we are working with the platform vendor to investigate and resolve it.
jblomqvist
Valued Contributor

Set Analysis for YTD calculation for Select Year and Month?

Hi all,

I am trying to create Set Analysis for an expression where I only want YTD values for the selected Year and Month.

Fields names:

Year: sample values, 2014, 2015, 2016, 2017, 2018 etc

Month: sample values Jan, Feb, Mar, Apr, Jun etc

Expression: Sum(Sales)

So for example if I select Year 2017, and Month April, I want to see the total of Sum(Sales) to include Jan, Feb, Mar, Apr 2017 values added up together.

If I select Year 2015 and July, it should be for all the months up to July 2015.

And so on.

Anybody know how to do this please?

4 Replies
Partner
Partner

Re: Set Analysis for YTD calculation for Select Year and Month?

Hi John,

You'll want to try =Sum({<Month = {'<=$(=Max(Month))'}>}Sales)

Note this does asume you are always selecting a year.

Please find an example attached. Is this what you're trying to achieve?

neelamsaroha157
Valued Contributor II

Re: Set Analysis for YTD calculation for Select Year and Month?

Create a variable for max date & create another variable as Yearstart(Max(Date)) and use these variables in set analysis.

Or you can do it without variable as well.

Sum({<Date=Date={">=$(=YearStart(Max(Date)))<=$(=Date(Max(Date)))"}>}Value)

Hope this helps.

neelamsaroha157
Valued Contributor II

Re: Set Analysis for YTD calculation for Select Year and Month?

Sorry, there is typo

It should be: Sum({<Date={">=$(=YearStart(Max(Date)))<=$(=Date(Max(Date)))"}>}Value)

Highlighted
ramya_grandhi
New Contributor III

Re: Set Analysis for YTD calculation for Select Year and Month?

John,

Sum( {<Year = {$(=GetFieldSelections(Year))},Month = {$(=GetFieldSelections(Month))}>} Sales)