Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
ioannagr
Creator III
Creator III

Selected year vs previous year

Hello everyone.

So I have an issue that I have spent so much time on and it's driving me crazy. I want to calculate the difference of the count of blooddonors this year vs previous year.

count({<[status] = {'0, '1, '2'},
[unitnumber] = {"=Len(unitnumber) = 12"},[donationyear] = {"$(=Max([donationyear]))"}>} distinct [blooddonor_id])-count({<[status] = {'0', '1', '2'},
[unitnumber] = {"=Len(unitnumber) = 12"},[donationyear] = {"$(=Max([donationyear])-1))"}>} distinct [blooddonor_id])
🤔

 

In the data manager i extracted the Year drom the donationdate and named it donationyear.

Yet it still isn't working. It returns the count of  donors for only the selected year.

 

Help?

13 Replies
tomovangel
Partner - Specialist
Partner - Specialist

Hello Sunny @sunny_talwar  Can you try to help this fellow, I couldn't do it, it seemed like an easy task, but not so much 🙂 
thanks in advance 🙂 

ioannagr
Creator III
Creator III
Author

I haven't been able to solve this yet 😞 

thank you Tomo for your interest 🙂

Rohan
Specialist
Specialist

Hello,

Please Try out the following set expression, I think this should satisfy the requirement.

(Expression A) -(Expression B).

Expression A will be as follows :

Count({<donationdate ={">=$(=date(yearstart(max(donationdate )))) <=$(=date(max(donationdate )))"}>}blooddonor_id)


Expression B will be as follows :
Count({1<donationdate ={">=$(=date(Addyears(yearstart(max(donationdate )),-1))) <=$(=date(Addyears(max(date),-1)))"}>}blooddonor_id)

 Also, you can add the other restrictions in these set expressions as per your requirement.

Set_expression_2.jpg

The image will give an idea about how the expression works.

Let me know if this works out or if you have any queries.

 

Thanks & Regards.

Rohan S. Desai.

sunny_talwar

Two things

  • Are you making selection in donationyear or are you making selection in any other date field also? If you do, then you might want to ignore selection in those date fields in your previous year expression.
  • Your expression for previous year is not entirely correct. This might be a typo, but make sure this is correct

Count({<[status] = {'0', '1', '2'}, [unitnumber] = {"=Len(unitnumber) = 12"}, [donationyear] = {"$(=Max([donationyear])-1))"}>} DISTINCT [blooddonor_id])

So, try this for previous year

Count({<[status] = {'0', '1', '2'}, [unitnumber] = {"=Len(unitnumber) = 12"}, [donationyear] = {"$(=Max([donationyear])-1)"}>} DISTINCT [blooddonor_id])