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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set Analysis - This Week, Last Year

Hi All,

Can anybody help me please as I can't spot where I am going wrong with my expression and I've only been looking at it for over a day now!

I want to be able to calculate the agregated sum for the selectd weeks data but from the Previous year. I did think this was easy but the results I am getting back are the same for this year.

for this years data i am using the expression

Sum({$<year={$(=Only(Year))}, Week={$(=Only(Week))}>} SalesGross)

and for the previous years expression i am using:

Sum({$<year={$(=(Only(Year)-1))}, Week={$(=Only(Week))}>} SalesGross)

from my example I have attached, you will see that the lables and text box are retuning the right values so can't figure out what is wrong with my expression

Many thanks

Lawrence

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi,

please look for upper and lower case writings. As I see from your data model, the field "Year" exists, but not the field "year"

Use:

Sum({$<Year={$(=(Only(Year)-1))}, Week={$(=Only(Week))}>} SalesGross)

If you select this row in your model you will see the message "bad field "year". Correct it and you will see a difference!

Good luck!

instead of

Sum({$<year={$(=(Only(Year)-1))}, Week={$(=Only(Week))}>} SalesGross)

View solution in original post

2 Replies
Anonymous
Not applicable
Author

Hi,

please look for upper and lower case writings. As I see from your data model, the field "Year" exists, but not the field "year"

Use:

Sum({$<Year={$(=(Only(Year)-1))}, Week={$(=Only(Week))}>} SalesGross)

If you select this row in your model you will see the message "bad field "year". Correct it and you will see a difference!

Good luck!

instead of

Sum({$<year={$(=(Only(Year)-1))}, Week={$(=Only(Week))}>} SalesGross)

Not applicable
Author

Thanks very much for your help, but i now feel such a complete idiot.

Kind regards

Lawrence