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: 
nagasekhar
Contributor III
Contributor III

ytd expression error

=Sum({<OrderDate={">=$(=yearstart(addyears(max(OrderDate)),-1)<=$(=addyears(max(OrderDate)),-1))}>"}Sales)

this expression showing error[error in set modifier expression]

how to resolve it

1 Solution

Accepted Solutions
marcus_sommer

You need something like this:

=Sum({< Year, OrderDate = {">=$(=date(yearstart(addyears(max(OrderDate),-1)), 'DD/MM/YYYY'))<=$(=date(addyears(max(OrderDate),-1), 'DD/MM/YYYY'))"}>} Sales)

whereby your trouble is caused from different formatting. Your OrderDate is 'DD/MM/YYYY' but your default format for dates within the application defined by the interpreting-variables at the script-start in tab Main is 'MM/DD/YYYY'.

IMO all dates and their interpretation within an application should have the same format und further I suggest to avoid all such trouble by using pure numeric values for each kind of matching and calculations. This means in your case just to double the OrderDate with an additionally floor(OrderDate) as OrderDateNum and then you could mostly use num() or floor() to call the comparing/calculation wherever you need it.

- Marcus 

View solution in original post

18 Replies
jyothish8807
Master II
Master II

Try this:

=Sum({<OrderDate={">=$(=yearstart(addyears(max(OrderDate),-1))<=$(=addyears(max(OrderDate),-1))"}>}Sales)

Best Regards,
KC
nagasekhar
Contributor III
Contributor III
Author

thanks for replying

but still it is throwing error

Screenshot (12060).png

marcus_sommer

The variables needs to be wrapped with single-quotes like:

=Sum({<OrderDate={">='$(=yearstart(addyears(max(OrderDate),-1))'
                                             <='$(=addyears(max(OrderDate),-1))'"}>}Sales)

- Marcus 

jyothish8807
Master II
Master II

Hi @nagasekhar ,

Try this, ')' was missing:

=Sum({<OrderDate={">='$(=yearstart(addyears(max(OrderDate),-1)))'
                                             <='$(=addyears(max(OrderDate),-1))'"}>}Sales)

Best Regards,
KC
nagasekhar
Contributor III
Contributor III
Author

Hai jyothish

I need to learn qlik sense administration

If you have any videos 

Please send me

Mail: nag78936@gmail.com

nagasekhar
Contributor III
Contributor III
Author

Hai marcus_sommer

I need to learn qlik sense administration

If you have any videos 

Please send me

Mail: nag78936@gmail.com

jyothish8807
Master II
Master II

Hi @nagasekhar ,

I think the community what we have is the best place to learn also look out in youtube, there are lot of videos available  🙂

Also please close the thread by marking the correct answer if it helps 🙂 

Best Regards,
KC
nagasekhar
Contributor III
Contributor III
Author

if i use simple set analysis i am getting (where 2010 is max date)

=sum({<Year={2009}>}Sales)

Screenshot 2021-10-01 114521.png

but while using ytd i am getting error

Screenshot 2021-10-01 114846.png

marcus_sommer

This bracket is missing: ... '$(=yearstart(addyears(max(OrderDate),-1)))' ...

- Marcus