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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
pranaview
Creator III
Creator III

Using MonthName function in a set expression is not working as expected

Hi Guys,

I have to get average of records for last 3 months. I was using below logic to get it but am not getting correct result.

=Avg({<MonthYear ={$(=MonthName(Addmonths(today(),-1))),$(=MonthName(Addmonths(today(),-2))),$(=MonthName(Addmonths(today(),-3)))}>}Field)

where the expression =MonthName(Addmonths(today(),-1)) will give you Dec 2018 and MonthYear field is MonthName(Date)

I think it's because of the $ expansion there might be something going wrong but i am not sure. 

Although when I use the following expression, i get the correct result.

=Avg({<MonthYear = {"=MonthYear =MonthName(Addmonths(today(),-2))","=MonthYear =MonthName(Addmonths(today(),-3))","=MonthYear =MonthName(Addmonths(today(),-4))"}>}Field)

I know i could have just used the second expression but I am curious why the first one did not work or is there any better solution to this problem than second expression.

Any input would be appreciated.

Cheers,

Pranav

 

Labels (1)
1 Reply
shiveshsingh
Master
Master

You need to use quotes as well.