Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to give two conditions for same field in set analysis?

Hi,

Below is my original set expression:

=sum({<Year={$(vPriorYear)}, TRANSACTION_DATE={'>=$(=YearStart(max(TRANSACTION_DATE),-1))<=$(=AddYears(max(TRANSACTION_DATE),-1))' }>} NTPV_AMT)

Now I want to add one more condition on TRANSACTION_DATE,

TRANSACTION_DATE={'>=$(=Date(date(max(TRANSACTION_DATE)-(vDays))))<=$(max(TRANSACTION_DATE))'}

I tried doing it with AND but it didn't work.

=sum({<Year={$(vPriorYear)}, TRANSACTION_DATE={'>=$(=YearStart(max(TRANSACTION_DATE),-1))<=$(=AddYears(max(TRANSACTION_DATE),-1))'  AND

'>=$(=Date(date(max(TRANSACTION_DATE)-(vDays))))<=$(max(TRANSACTION_DATE))'

}>} NTPV_AMT)

Any suggestions or help on how to achieve it.

--Sachin

22 Replies
sunny_talwar

Can you try this:

=Sum({<Year={$(vPriorYear)}, TRANSACTION_DATE = {

'>=$(=YearStart(Max(TRANSACTION_DATE),-1))<=$(=AddYears(Max(TRANSACTION_DATE),-1))',

'>=$(=Date(Date(Max(TRANSACTION_DATE)-(vDays))))<=$(Max(TRANSACTION_DATE))'

}>} NTPV_AMT)

trdandamudi
Master II
Master II

Give the below a try:

=sum({<Year={$(vPriorYear)}, TRANSACTION_DATE={'>=$(=YearStart(max(TRANSACTION_DATE),-1))<=$(=AddYears(max(TRANSACTION_DATE),-1))' ,

'>=$(=Date(date(max(TRANSACTION_DATE)-(vDays))))<=$(max(TRANSACTION_DATE))'

}>} NTPV_AMT)

phaneendra_kunc
Partner - Specialist III
Partner - Specialist III

Try adding a new field in the script ..


num(floor(TRANSACTION_DATE)) as TRANSACTION_DATE_NUM


and this..see the brackets...

TRANSACTION_DATE_NUM={'>=$(=max(TRANSACTION_DATE_NUM)-(vDays))<=$(=(max(TRANSACTION_DATE_NUM))'}

Not applicable
Author

Didn't work Sunny.

Not applicable
Author

It didnt' work, Thirumala..

Not applicable
Author

Hi Phanee,

I already had a field, num(TRANSACTION_DATE) as TRANSACTION_DATE_NUM, but it didn't work.

So now I'm changing it to num(floor(TRANSACTION_DATE)) as TRANSACTION_DATE_NUM

Will try again and see.

sunny_talwar

Are the two set expressions working stand alone?

Not applicable
Author

Yes, they are..

trdandamudi
Master II
Master II

What are the values you are getting when you run the two set expressions individually?