Qlik Community

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

cancel
Showing results for 
Search instead for 
Did you mean: 
carotravaglini
Contributor II
Contributor II

Comparing dates in an if statement

Hi! I need to compare 2 dates in order to count how many employees are at some time. 

I have a pivot table with month and year as dimensions.

if(date(Fecha) >= date(leg_fecing,'MM/dd/yyyy'), Count(leg_numero)- Count (leg_fecegr))

It's not working. How can i solve this?

Captura.PNG

Labels (2)
4 Replies
QFabian
Specialist II
Specialist II

Hi @carotravaglini , please try something like this :

 

Count(if(num(Fecha)>=num(leg_fecing), leg_numero))

-

Count(if(num(Fecha)>=num(leg_fecegr), leg_fecegr))

QFabian
carotravaglini
Contributor II
Contributor II
Author

Hi @Qfabian, thanks for the answer. I've got some results with your reply, but wrong ones. 

QFabian
Specialist II
Specialist II

Hi, checking your original formula, maybe it is like this:

Count(if(num(Fecha)>=num(leg_fecing), leg_numero))

-

Count(if(num(Fecha)>=num(leg_fecing), leg_fecegr))

QFabian
carotravaglini
Contributor II
Contributor II
Author

Thank you @QFabian , i found a solution with this formula and your idea was really helpfull:

count(distinct(leg_numero)) - count(distinct(if([leg_fecegr.autoCalendar.Date]<[Fecha.autoCalendar.Date],leg_numero))) - count(distinct(if([leg_fecing.autoCalendar.Date]>[Fecha.autoCalendar.Date],leg_numero)))