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: 
ananyaghosh
Creator III
Creator III

How to create Prior YTD sales calculations

Hi,

I have used the below calculation for prior YTD:

sum({$<[Order Date]={">=$(=YearStart(AddYears(Max([Order Date]),-1))) <=$(=AddYears(Max([Order Date]),-1)"}>}Sales)

and I have attached my application. But for Prior YTD column I am getting no values.

Please help me

5 Replies
sunny_talwar

Closing parenthesis missing

sum({$<[Order Date]={">=$(=YearStart(AddYears(Max([Order Date]),-1)))<=$(=AddYears(Max([Order Date]),-1))"}>}Sales)

ananyaghosh
Creator III
Creator III
Author

hi,

I have used your expression, but when I select a year value from select list I got 0 for all the rows for that column. So is anything wrong here or I cannot select year from dropdown?

Thanks,

Sandip

sunny_talwar

Ignore selection in Year my friend.... Are you unfamiliar with set analysis basics?

Sum({$<[Order Date]={">=$(=YearStart(AddYears(Max([Order Date]),-1)))<=$(=AddYears(Max([Order Date]),-1))"}, Year>}Sales)

ananyaghosh
Creator III
Creator III
Author

Hi,

I am taking apology for this , but may I know that why I need to use 'Year=' here?

Actually I am using this:

Sum({<Year=,DayNumber=,MonthName=,[Order Date]={">=$(=YearStart(AddYears(Max([Order Date]),-1))) <=$(=AddYears(MonthEnd(Max([Order Date])),-1))"}>}Sales)

So for calculating the MTD and YTD is it will be same?

sunny_talwar

When you select year 2015, your Order Date range will become 01/01/2014-12/31/2014. So if you don't ignore Year, the two will contradict each other. So, in your case, year selection will indirectly drive your Order Date to give you the right output as long as you ignore selection in Year field.

So for calculating the MTD and YTD is it will be same?

Don't know what you mean here