Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Addmonths in Set Analysis ( next 3 months)

Hello,

Guys need your help!

I want to create an expression with average of next three months. I tried to use this one with addmonths function, but it's not working

Avg({<Month_name={">=$(=Date(addmonths(Month_name,1),'MMM'))<=$(=Date(addmonths(Month_name,3),'MMM'))"}>} Values)

Please help!

1 Solution

Accepted Solutions
PrashantSangle

Hi,

I have tested data let me know what was your expecting output.

It is working at my end.

testCase:

Selected Month : Mar

Employee Name : Itojqj Tygnss

Expected Avg for next 3 month is sum(Apr,May,Jun)/3

Result :

Then Bench_data for Apr,May jun is 1.94

and Avg is 0.64666

Please find attached apps.

Regards,

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

View solution in original post

13 Replies
swuehl
MVP
MVP

You're applying a numeric search in your element list. Does field Month_name have a numeric representation (is it a dual value with a text and a numeric value, the numeric value showing monthstart date?

Maybe this is of some help:

The Magic of Set Analysis - Point In Time Reporting • Blog • AfterSync

PrashantSangle

Hi,

How did you create Month_name field or it is already availble in script???

If you are creating Month_name using Month(datefield)

then try

Avg({<datefield={">=$(=Date(addmonths(datefield,1)))<=$(=Date(addmonths(datefield,3)))"},Month_name=>} Values)

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Not applicable
Author

Hi,

i tried this one Avg({$<Month_Date={">=$(=addmonths(Month_Date,1))<=$(=addmonths(Month_Date,3))"},Month_Date=>}Bench_Data)

and it worked but incorrectly.

The thing is the user picks several months in the filter like : from Jan till Jun, from Jan till July etc. And I want the table to show the average of next 3 months.

For example, if the user selects the months from January till June, I want it to show the average of values starting from July till September.

Not applicable
Author

Month_name field was created in the script

antoniotiman
Master III
Master III

Hi Diana,

add Max() in AddMonths

AddMonths(Max(Month_Date),1)  and ,3 (maybe 4)

and remove Month_Date= from set analysis

Regards,

Antonio

PrashantSangle

Hi,

Use max() to get max of selected months

try like

Avg({$<Month_Date={">=$(=addmonths(max(Month_Date),1))<=$(=addmonths(max(Month_Date),3))"},Month_Date=>}Bench_Data)

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Not applicable
Author

It doesnt seem to work correctly, I checked again, and it gives me the wrong result. It seems to get the average of the max month. Like if you choose June for example, it gives you the average of previous months, from January till June... This is odd

PrashantSangle

Hi,

Is it possible to share app???

debug your code by remove label name of expression then on front end put pointer on that expression,

You will get value in set expression.

Just check it ,what it is showing???

And possible post screen shot of it

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Not applicable
Author

Max,

Sorry, I dont understand how to make all these corrections.

Here is my sample app, would be greateful for help.

Thank You! ! !