Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

amit_saini
Honored Contributor III

Previous YTD Help

Hi All,

Here’s the question I had about qlikview. I want to calculate Previous YTD (Same time frame as the current year) however, whenever I reload my data, the Prev YTD column stays static and the current year data changes based on the new data.

I expect the Prev YTD column to look back in time and fetch data for the same time frame as last year and keep accumulating each time I reload data.

I'm using something like below , but looks like it's not working.

=SUM({$<SalesDate={'>=$(=AddYears(YearStart(Today()),-1))<=$(=AddYears(Date(Today()),-1))'}>}InvoiceSales)

Any suggestions?

Regards,

AS

6 Replies
amit_saini
Honored Contributor III

Re: Previous YTD Help

Guys any suggestion?

Regards,

AS

Re: Previous YTD Help

May be try this

=Sum({$<SalesDate = {">=$(=Date(YearStart(Today(), -1), 'DateFieldFormatHere'))<=$(=Date(AddYears(Today(), -1), 'DateFieldFormatHere'))"}>} InvoiceSales)

amit_saini
Honored Contributor III

Re: Previous YTD Help

Hi Sunny,

I tried below:

=Sum({$<SalesDate = {">=$(=Date(YearStart(Today(), -1), 'M/D/YYYY'))<=$(=Date(AddYears(Today(), -1), 'M/D/YYYY'))"}>} InvoiceSales)


Sorry no luck!


Regards,

AS

pradosh_thakur
Valued Contributor III

Re: Previous YTD Help

=Sum({$<SalesDate = {">=$(=Date(YearStart(max(SalesDate), -1), 'M/D/YYYY'))<=$(=Date(AddYears(max(SalesDate), -1), 'M/D/YYYY'))"}>} InvoiceSales)

Re: Previous YTD Help

Are you making a selection in the year field or yearmonth or something related?? May be try this

=Sum({$<SalesDate = {">=$(=Date(YearStart(Today(), -1), 'M/D/YYYY'))<=$(=Date(AddYears(Today(), -1), 'M/D/YYYY'))"}, Year, Month, MonthYear, Quarter, QuarterYear>} InvoiceSales)

pablolabbe
Valued Contributor II

Re: Previous YTD Help

When applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads as HELPFUL if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads as HELPFUL if you feel additional info is useful to others

Community Browser