Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
gouthamkk
Creator
Creator

QlikView set Analysis for Data Range

HI,

I wrote a set analysis expression as below

=Avg({<Date= {'>=$(=AddMonths(Max(MonthName),-24)) <=$(=MonthEnd(Max(MonthName),-1))'}>} val)

when no selections made i am getting correct result. but if i select a MonthName(eg: Jun 2016-- ListBox), the expression is not displaying any result.

If i select any month name, the expression has to to average of all past 24 months.

Can some one please Advise.

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Just add all calendar fields the use may select in to your set analysis:

Avg({<Date= {'>=$(=AddMonths(Max(MonthName),-24)) <=$(=MonthEnd(Max(MonthName),-1))'},MonthName=, Year= >} val)

View solution in original post

5 Replies
swuehl
MVP
MVP

Try

=Avg({<Date= {'>=$(=AddMonths(Max(MonthName),-24)) <=$(=MonthEnd(Max(MonthName),-1))'}, MonthName=>} val)


i.e. clear selection in MonthName in your set expression to avoid an incompatible set (note that your Date field date range does not cover your active selection).

gouthamkk
Creator
Creator
Author

Yes, i tried this but i also want a flexibility to select date field, that's why in the second part of the expression i am using MonthEnd() function(Bold letters below)

Avg({<Date= {'>=$(=AddMonths(Max(MonthName),-24)) <=$(=MonthEnd(Max(MonthName),-1))'}, MonthName=>} val)

swuehl
MVP
MVP

Not sure if I understand your issue. The expression should still be sensitive to selection in MonthName field (the max() function in the dollar sign expansions should return your max selected value).

You still get no result when you are selecting a value? Could you upload a small sample QVW?

gouthamkk
Creator
Creator
Author

when i select a value from Year list box(eg: 2016) the values is changing and i am getting the average for only 2016 data set.

i still want my expression to calculate for past 24 months starting from max of the month.

i really appreciate all you help

swuehl
MVP
MVP

Just add all calendar fields the use may select in to your set analysis:

Avg({<Date= {'>=$(=AddMonths(Max(MonthName),-24)) <=$(=MonthEnd(Max(MonthName),-1))'},MonthName=, Year= >} val)