Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
HI Qlik Experts
I have a dataset containing sales data which ranges from 1 Apr 2007 to 31 Mar 2009.
I am currently comparing the YTD and LYTD sales and have the below script which looks fine and returns me the accurate YTD and LYTD for any particular selection I wanted.
vMaxYear=max(Year)
vPriorYear=vMaxYear -1
vMaxDate=max(Date)
vPriorYearDate=date(addyears(max(Date), -1), 'DD/MM/YYYY')
YTD ='YTD $(vMaxDate)' |
LYTD ='YTD $(vPriorYearDate)' |
=SUM({< Year={"$(vMaxYear)"}, Month=, Day=, Date={"<=$(vMaxDate)"}, MonthYear= >}Sales) |
=SUM({< Year={'$(vPriorYear)'}, Month=, Day=, Date={'<=$(vPriorYearDate)'}, MonthYear= >}Sales) |
However, my issue with this script is when I am not selecting any dates, by default it gives me the YTD for 2009 (till 31 Mar which is the max date) and the Sum of Sales of entire year for 2008 for my LYTD. I wish to let the default for LYTD be until 31 Mar 2008 as well.
Any advise on this??? Thank youuu!
As per attached.