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: 
DanTrousdale
Contributor
Contributor

Previous Year KPI

Hi, I have a KPI (KPI A) which displays the current year enrolments at a university. I would like to create a KPI (KPI B) which displays the enrolments for the previous year to whatever years enrolment is displayed in KPI A. For example, if KPI A displays 2018/19 Enrolments. I would like KPI B to display Enrolments for 2017/18. I would also like this to be dynamic. 

Thanks in advance.

Labels (2)
7 Replies
Anil_Babu_Samineni
MVP
MVP

How is the field generating for 2018/19 ? You can try this way

For This year : Count({<Year = {$(=Max(Year))}>} Field)

For prev. Year : Count({<Year = {$(=Max(Year-1))}>} Field)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
StarinieriG
Partner - Specialist
Partner - Specialist

Hi,

try to do something like this

1) Create two variables

CurrentYear  = Max(Year)

PreviousYear = Max(Year)-1

2) Use YEAR field

KPI A : Sum({<YEAR = {$(CurrentYear)}>} Value)

KPI B: Sum({<YEAR = {$(PreviousYear )}>} Value)

DanTrousdale
Contributor
Contributor
Author

Thanks for the response Anil, this works but only for the max year. when a previous year is selected the KPI fails to show the year previous to that. IE if I wanted to see the enrolments for 2017/18, KPI B would need to show the enrolments for 2016/17.

Thanks

dan

DanTrousdale
Contributor
Contributor
Author

Thanks for the response, this works but only for the max year. when a previous year is selected the KPI fails to show the year previous to that. IE if I wanted to see the enrolments for 2017/18, KPI B would need to show the enrolments for 2016/17.

Thanks

dan

Anil_Babu_Samineni
MVP
MVP

Try that and let me know else can you share sample file where it fails?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
DanTrousdale
Contributor
Contributor
Author

It seems to fail when KPI A is displaying a year which isn't the current max year, unable to share file due to sensitive data.

Anil_Babu_Samineni
MVP
MVP

can you share images of 2 KPI's using

Max(Year)

Max(Year-1)

And, Then select something then show what are you getting with 2 images after?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful