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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
nareshthavidishetty
Creator III
Creator III

YTD Calculation

Hi ,

I need to compare this year YTD with Lastyear YTD sales.

Date= SoldDate

Ex:Untitled.png

Thanks..

Labels (1)
21 Replies
sunny_talwar
MVP
MVP

Try this:

=Sum({<SoldDate = {

"$(='>=' & Date(YearStart(Max(SoldDate), 0), 'M/D/YYYY') & '<=' & Date(AddYears(Max(SoldDate), 0), 'M/D/YYYY'))",

"$(='>=' & Date(YearStart(Max(SoldDate), -1), 'M/D/YYYY') & '<=' & Date(AddYears(Max(SoldDate), -1), 'M/D/YYYY'))",

"$(='>=' & Date(YearStart(Max(SoldDate), -2), 'M/D/YYYY') & '<=' & Date(AddYears(Max(SoldDate), -2), 'M/D/YYYY'))",

"$(='>=' & Date(YearStart(Max(SoldDate), -3), 'M/D/YYYY') & '<=' & Date(AddYears(Max(SoldDate), -3), 'M/D/YYYY'))"

}, SoldMonth, SoldYear>}ESTCUST)


Capture.PNG

nareshthavidishetty
Creator III
Creator III
Author

Hi Sunny,

It's working fine.

Is the below logic works for MTD as same as YTD.

=Sum({<SoldDate = {

"$(='>=' & Date(MonthStart(Max(SoldDate), 0), 'M/D/YYYY') & '<=' & Date(AddYears(Max(SoldDate), 0), 'M/D/YYYY'))",

"$(='>=' & Date(MonthStart(Max(SoldDate), -1), 'M/D/YYYY') & '<=' & Date(AddYears(Max(SoldDate), -1), 'M/D/YYYY'))",

"$(='>=' & Date(MonthStartMonthStart(Max(SoldDate), -2), 'M/D/YYYY') & '<=' & Date(AddYears(Max(SoldDate), -2), 'M/D/YYYY'))",

"$(='>=' & Date(MonthStart(Max(SoldDate), -3), 'M/D/YYYY') & '<=' & Date(AddYears(Max(SoldDate), -3), 'M/D/YYYY'))"

}, SoldMonth, SoldYear>}ESTCUST)

Thanks..

sunny_talwar
MVP
MVP

You want to still show 2014, 2015, 2016, & 2017?

nareshthavidishetty
Creator III
Creator III
Author

Yes.

I need to show year as well.

Thanks..

sunny_talwar
MVP
MVP

May be this

=Sum({<SoldDate = {

"$(='>=' & Date(MonthStart(AddYears(Max(SoldDate), 0)), 'M/D/YYYY') & '<=' & Date(AddYears(Max(SoldDate), 0), 'M/D/YYYY'))",

"$(='>=' & Date(MonthStart(AddYears(Max(SoldDate), -1)), 'M/D/YYYY') & '<=' & Date(AddYears(Max(SoldDate), -1), 'M/D/YYYY'))",

"$(='>=' & Date(MonthStart(AddYears(Max(SoldDate), -2)), 'M/D/YYYY') & '<=' & Date(AddYears(Max(SoldDate), -2), 'M/D/YYYY'))",

"$(='>=' & Date(MonthStart(AddYears(Max(SoldDate), -3)), 'M/D/YYYY') & '<=' & Date(AddYears(Max(SoldDate), -3), 'M/D/YYYY'))"

}, SoldMonth, SoldYear>}ESTCUST)

nareshthavidishetty
Creator III
Creator III
Author

Hi,

Got results but it is showing only for month dec.

I have checked the data is available.

Thanks..

sunny_talwar
MVP
MVP

Month is a dimension? I am not sure what you doing, can you share an updated sample?

nareshthavidishetty
Creator III
Creator III
Author

Thanks..

Is the below expression is correct for WTD.

=Sum({<SoldDate = {

"$(='>=' & Date(WeekStart(AddYears(Max(SoldDate), 0)), 'M/D/YYYY') & '<=' & Date(AddYears(Max(SoldDate), 0), 'M/D/YYYY'))",

"$(='>=' & Date(WeekStart(AddYears(Max(SoldDate), -1)), 'M/D/YYYY') & '<=' & Date(AddYears(Max(SoldDate), -1), 'M/D/YYYY'))",

"$(='>=' & Date(WeekStart(AddYears(Max(SoldDate), -2)), 'M/D/YYYY') & '<=' & Date(AddYears(Max(SoldDate), -2), 'M/D/YYYY'))",

"$(='>=' & Date(WeekStart(AddYears(Max(SoldDate), -3)), 'M/D/YYYY') & '<=' & Date(AddYears(Max(SoldDate), -3), 'M/D/YYYY'))"

}, SoldMonth, SoldYear>}ESTCUST)

Thanks..

nareshthavidishetty
Creator III
Creator III
Author

sunny_talwar
MVP
MVP

That is disheartening to see that after so much effort from my end, you marked your own response as correct. You did not find a single expression provided by me to be correct, not even helpful?