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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set Analysis syntax - sum sales between dates

Hi There,
Am wondering if someone can assist with the below set analysis syntax?

sum(
{
<
SALE_DT >= AddMonths(MakeDate(Year(Now()), Month(Now()), '01'), -12)
,
SALE_DT <= MakeDate(Year(Now()), Month(Now()), '01')
>
}
SALES_AMT
)

I need to get the sum of sales between the sales date range of

01/JUNE/2008 and 01/JUL/2009

Unfortunately Qlikview 8.5 does not flag if Set analysis syntax is incorrect or have a query builder for set analysis.

Thanks,
Kevin.

1 Reply
Not applicable
Author

Your syntax is a little off. First, you can't use >= or <= where you are. There, you need a Set Operator. Replace those with equal signs.

You're also missing the brackets around your Set Modifiers.

Then you need to do the greater than or equal and the date expression inside a dollar sign expansion. Dates seem to be the most difficult to get right when doing Set Analysis for me. I usually end up trying out a few different things before getting it right.

Try this:

sum({<SALE_DT = {'>= $(=AddMonths(MakeDate(Year(Now()), Month(Now()), '01'), -12))},
SALE_DT = {'<= $(MakeDate(Year(Now()), Month(Now()), '01'))}>} SALES_AMT)