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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
nachofernandez
Partner - Contributor III
Partner - Contributor III

AddMonths problem in Set Analysis

Hi,

i´m experiencing some problems related to the use of this function with set analysis.

My requeriment is to calculate the sum of sales in a three month period of time based in the Start Date of a Campaign.

I have this data:

idSalesDateSales
1201801010
12018020110.000
12018030140.000
12018040150.000

So, the result for Id=1 should be 50.000 when selecting 20180101

But i can´t get this value. My attempts are:

- sum({$<SalesDate={">=$(=20180101)<=$(=20180301)"}>}Sales)

    This goes ok. Result=50.000


- sum({$<SalesDate={">=$(=Date(Start_Date))<=$(=20180301)"}>}Sales)---->Start_Date=20180101 in this case.

    This goes ok. Result=50.000

- sum({$<SalesDate={">=$(Date(Start_Date))<=$(AddMonths(Date(Start_Date),2))"}>}Sales)

           --->AddMonths(Date(Start_Date),2)=20180301 in this case.

    This goes wrong. Result=100.000



It seems AddMonths function is not working. Any idea would be appreciated.


Thanks in advance.

Regards.

Labels (1)
11 Replies
nachofernandez
Partner - Contributor III
Partner - Contributor III
Author

Almost got it.

I´ve changed the scritp and now they´re connected.

If i select ID 1 it works. If i don´t select anything, the result is 0.

I need the table complete, without selecting anything.

nachofernandez
Partner - Contributor III
Partner - Contributor III
Author

I think I´ve found the solution.

It seems Set Analysis is not applicable to this situation. Just if a record or a date is selected, but with no selection it doesn´t work. Changing it for an if function, it works very well.

Thank you very much for all the answers. They helped me a lot.