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

how to use expressions to get sales data in previous year

Hi There,

I am creating a chart trying to show the comparison of sales in the year user selected and the previous year. User can select multiple Order Dates  (e.g. 01/01/2014,01/02/2014,01/03/2014,01/04,2014) to see how much sales generated in those days.  I have successfully loaded a master calendar with Year, Month and Day associated with Order Date. When I list Year, Month and Day in listbox, it gives me 2014, Jan, 01,02,03,04. With all these conditions, how can I use expressions to get the sales in the period from 01/01/2013 to 01/04/2013?

Thank you so much!

Best Regards,

Gloria

1 Reply
ashfaq_haseeb
Champion III
Champion III

Hi,

Try below

1. Current Year

=Sum({$<Month=, Date=, Year={$(=Only(Year))}>} Sales)

or

=sum({<Month=, Date=, Year={$(=max(Year))}>}Sales)

2. Previous Year

=Sum({$<Month=, Date=, Year={$(=Only(Year)-1)}>} Sales)

or

=sum({<Month=, Date=, Year={$(=max(Year)-1)}>}Sales)

Replace with appropriate field names.

Regards

ASHFAQ