Skip to main content
Announcements
Qlik Announces Qlik Talend Cloud and Qlik Answers: LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
bhagi
Contributor II
Contributor II

set exp

hi all,

i need set expression 

sum (sales)

filter1 : addmonths -2 (2 months before today)

filter2 : country=USA

 

how to use set expression?

 

thnks

bhagi

Labels (4)
5 Replies
Taoufiq_Zarra

@bhagi  like ?

=Sum({<date={">=$(=addmonths(today(),-2))"},country={'USA'}>} Sales)
Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Taoufiq_Zarra

@bhagi  if you have doubts about date format you can use this version with your default date format

Sum({<date={">=$(=Date(addmonths(today(),-2),'DD/MM/YYYY'))"},country={'USA'}>} Sales)
Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Chanty4u
MVP
MVP

Hi you can try this.

=Sum({<country = {'USA'}, Num_Month = {$(=Max(Num_Month)-2)}>}sales)

 

convert your month in number format foe better results.

 

Chanty4u
MVP
MVP

or try this

Sum({<DateField = {">=$(=AddMonths(Date(Today()), -2)) <=$(=Date(Today()-1))"}, country = {'USA'}>}sales)

Brett_Bleess
Former Employee
Former Employee

@bhagi you have received multiple responses to your use case, we would greatly appreciate if you would return to the thread and close it out by using the Accept as Solution button on the post(s) that helped you get a working solution.  If you did something different, you may post that and then use the button to mark that post.

Here are some Design Blog post links that may be helpful as well:

https://community.qlik.com/t5/Qlik-Design-Blog/A-Primer-on-Set-Analysis/ba-p/1468344

https://community.qlik.com/t5/Qlik-Design-Blog/Set-Analysis-in-the-Aggr-function/ba-p/1463822

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.