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

Announcements
ALERT: QlikView server communication interruptions following Microsoft Windows Domain Controller security updates
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Current year vs Previous year

I have these fields in my database, PayRollYear and PayRollMonth and EMPNO.

I want to create a combo chart, that shows the count of employees in the present year vs the previous year. Present year would be a bar chart, and previous year would be a line chart, month being the dimension. Any ideas????

Labels (1)
9 Replies
Michiel_QV_Fan
Specialist
Specialist

Create 2 expressions for the count:

sum({<PayRollYear = {'2015'}>}EMPNO)

sum({<PayRollYear = {'2014'}>}EMPNO)


add month to the bar and set the 2 expressions as desired to line or bar.


also consider to use max(year) and max(year)-1 to make the year dependent on your year selection

Not applicable
Author

This works fine, but if I use, year and year-1, it does not work. Gives the same value for both. MichielvandeGoor

its_anandrjs
Champion III
Champion III

Hi,

Try to use with Max and Max - 1

For Current Year

sum({<PayRollYear = {'$(Max(PayRollYear))'}>}EMPNO)

For Previous Year

sum({<PayRollYear = {'$(Max(PayRollYear)-1)'}>}EMPNO)


Or


sum({<PayRollYear = {'$(Year(Date(Max(PayRollYear)-1)))'}>}EMPNO)


Regards

Anand

Anonymous
Not applicable
Author

Hi,

Create a graph with dimension Month and two expressions:

First expression in bar chart:

count(distinct {<PayRollYear ={$(=Max(PayRollYear))}>}EMPNO)

Second expression in line chart:

count(distinct {<PayRollYear ={$(=(Max(PayRollYear)-1))}>}EMPNO)

Michiel_QV_Fan
Specialist
Specialist

You need to eliminate the year selection if you use set analysis> Just add year =  to your set analysis


sum({<PayRollYear = "$(=Max(PayRollYear ))"}, PayRollYear =>}EMPNO)

sum({<PayRollYear = = {"$(=Max(PayRollYear ) -1)"}, PayRollYear =>}EMPNO)

Not applicable
Author

Thanks a lot! Much appreciated.

Not applicable
Author

Thanks a ton! It works!

Michiel_QV_Fan
Specialist
Specialist

Please give points to express your thanks

Anonymous
Not applicable
Author

that's great 🙂

please mark the discussion as solved if the question is solved for you