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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
WernerDC
Creator
Creator

Cy vs PY

Hi Guys, how do I write this formula to show the previous years data? This is my current year selection. I want to show how the data looked exactly the same time last year.

 

WernerDC_0-1618217785635.png

 

2 Solutions

Accepted Solutions
MuhammadFahim
Partner - Contributor II
Partner - Contributor II

You can use Addyears function in your vDateStart and vDateEnd.

Addyears(vDateStart,-1)
Addyears(vDateEnd,-1) 

it will return the start and end dates of  the same period of last year

View solution in original post

MayilVahanan

HI @WernerDC 

Instead of If condition, Try with set analysis like below

sum({<dateEntry_det={">=$(=AddYears($(vDateStart),-1))<=$(=AddYears($(vDateEnd),-1))"}, serviceCode_det={30}>}qtyHa_det)

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

4 Replies
MuhammadFahim
Partner - Contributor II
Partner - Contributor II

You can use Addyears function in your vDateStart and vDateEnd.

Addyears(vDateStart,-1)
Addyears(vDateEnd,-1) 

it will return the start and end dates of  the same period of last year

WernerDC
Creator
Creator
Author

Thank you

MayilVahanan

HI @WernerDC 

Instead of If condition, Try with set analysis like below

sum({<dateEntry_det={">=$(=AddYears($(vDateStart),-1))<=$(=AddYears($(vDateEnd),-1))"}, serviceCode_det={30}>}qtyHa_det)

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
WernerDC
Creator
Creator
Author

Thank you

Community Browser