Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Sum range for a selected year

Hello world,

If I want to sum the range of months for a selected year, and I cannot use year-to-date? Is it possible

For example if I select jun 2013

I want to se jan.. jun 2013 (From January to Jun)

I try to do it like the YTD and the master calendar, but it will not work, because I only have old dates - not dates in 2015.

How can we do this without using the current year flags?

Would it be with a selected year flag or something like that?

Regards Martha

1 Solution

Accepted Solutions
Not applicable
Author

output.PNG

Hi check the output. if this is what you wanted i will post the code

View solution in original post

17 Replies
swuehl
MVP
MVP

You can try something like

=Only(aggr(rangesum(above( sum({1}Value),0,rowno())),Year,Month))

This will only show a value, when you select a YearMonth, like Jun 2013.

You need to take care that load order of Year and Month is chronologic.

Instead of {1} set identifier, you can only clear all calendar fields, so further selections will be considered in the aggregation.

Not applicable
Author

Hi Swuehl,

Thank you very much for your answer.

I am testing it - it only gives me a value. I don't quite understand the {1}

I am trying to analize it

swuehl
MVP
MVP

You can also go for a script based solution:

Calculating rolling n-period totals, averages or other aggregations

The set identifier {1} is part of set analysis skills. With set analysis, you can modify user selections (here I just ignored any user selection in the inner aggregation).

Not applicable
Author

Yes I can see. I will try it with {$}

Thanks for you answer.

swuehl
MVP
MVP

{$} will not be enough, because it will just apply the user selection, limiting the sum() to Jun 2013 again.

At least you should clear selections on the calendar fields:

=Only(aggr(rangesum(above( sum({$<Month=, Year=, YearMonth= >}Value),0,rowno())),Year,Month))

Not applicable
Author

But I can see that aggregating a range would work if we have the months as dimensions.

Without any other dimension.

Because what it does is: sum the rows..

Not applicable
Author

But actually helps me a lot - thanks swuehl

  Regards

Martha

Not applicable
Author

Kindly attach some sample file which illustrates what you need actually...

it will help all of us to solve the issue

Not applicable
Author

you mean you selected year 2014 and month jul..? and the above is the output..?