Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
newuser
Creator II
Creator II

Prior Year KPI Empty if Current Year Selected

Hi group - our prior year KPI isn't working; any ideas? Below are details.

1. We have a “current year” KPI that uses set analysis to pull the highest year as follows.

Count({$<paymentyear={"$(=max({$}paymentyear))"}>} distinct Invoice)

2. We also have a “prior year” KPI below that uses set analysis in a similar way. The extra logic for paymentmonth is so that if we are in June in the current year, we only pull through June of the prior year to keep apples-to-apples.

count({$<[paymentyear] = {$(=max({$}[paymentyear])-1)},

                [paymentmonth] = {"<=$(=max({$<[paymentyear]={$(=max({$}[paymentyear]))}>} [paymentmonth]))"}>}

    distinct Invoice )

3. We are finding different results depending on the app. The only reason that comes to mind is maybe our older apps have a “bug” that the newer apps fixed via a patch?

    1. Older apps: when the user explicitly selects current year in a filter selector, the prior year KPI still populates
    2. Newer apps: when the user explicitly selects current year in the filter selector, the prior year KPI is empty

I kind of see why Qlik is behaving the way described in 3(b) above, but is that working as designed? What we like about 3(a) is that it still allows the user to see the prior year KPI even if they’ve filtered for only the current year.

The only workaround we can think of to have 3(b) behave more like 3(a) is to use the {1} nomenclature in the prior year KPI to ignore the filter selection so that the prior year KPI still appears regardless of what filter the user has selected; however, as you know, the drawback with using {1} is, all filters are ignored, so that is a bit inflexible.

We would ideally like to have 3(a) but aren’t sure how to achieve that while still letting the prior year KPI respect any other filters.

Thanks for your time and brains!

4 Replies
sasikanth
Master
Master

Set analysis logic should work irrespective of Old or New apps, 

Prior Year expression can also write like , 

count({$<[paymentyear] = {$(= Year(max(PaymentDate))-1)},

                [paymentmonth] = {"$(=Month(max(paymentDate)))"}>}

    distinct Invoice )

*Month format should be 'Jan','Feb' etc.

 

if possible please share sample app 

newuser
Creator II
Creator II
Author

Hi - tried that, and it still returns blank prior year if I select current year.

edwin
Master II
Master II

if you are computing for the prior year and current year on the fly in your set analysis, then the prior year will always be blank if PaymentDate is selected.   because the filter and the set analysis condition will be AND'ed.   

add PaymentDate= inside your set analysis.  

 

edwin
Master II
Master II

count({$<PaymentDate=, [paymentyear] = {$(= Year(max(PaymentDate))-1)},

                [paymentmonth] = {"$(=Month(max(PaymentDate)))"}>}

    distinct Invoice )