13 Replies Latest reply: Feb 13, 2015 9:25 AM by bobbyraj santhiogu

# Current year count vs Previous year count

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????

• ###### Re: Current year count vs Previous year count

Hello,

- Create a variable something like vMaxYear=max(Year).

- Another variable, PrevYear = vMaxYear-1

- Comcbo chart. 1 Dimension, Month; 2 Expressions:

sum({<Year='\$(vMaxYear)'>}Expression1)

sum({<Year='\$(vPrevYear)'>}Expression1)

BR

Serhan

• ###### Re: Current year count vs Previous year count

you mean, vMaxYear = max(PayRollYear)?

• ###### Re: Current year count vs Previous year count

Yes.

Sorry this is Qlik Sense though. You cannot create variables as in Sense.

sum({<Year={'\$(=max(PayRollYear))'}>}Expression1)

sum({<Year={'\$(=max(PayRollYear)-1)'}>}Expression1)

BR

Serhan

• ###### Re: Current year count vs Previous year count

Thanks a lot!

• ###### Re: Current year count vs Previous year count

I am using Qlikview, and if I do as you said, it's giving the same value for both, current and previous.

• ###### Re: Current year count vs Previous year count

Here we go.

BR

Serhan

• ###### Re: Current year count vs Previous year count

???

• ###### Re: Current year count vs Previous year count

Hello,

Open it in QlikView and just copy the formula. That's all.

BR

Serhan

• ###### Re: Current year count vs Previous year count

Hey,

I am sorry, but what am I suppose to open? There isn't any file attached, in you reply.

Shreya

• ###### Re: Current year count vs Previous year count

You can'see this?

• ###### Re: Current year count vs Previous year count

Nope!!!

• ###### Re: Current year count vs Previous year count

And also, where dao I create these variables?

• ###### Re: Current year count vs Previous year count

Hi,

No need to create variable in your case.

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)