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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
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 (1)
4 Replies
QFabian
MVP
MVP

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

Greetings!! Fabián Quezada (QFabian)
did it work for you? give like and mark the solution as accepted.
carotravaglini
Contributor II
Contributor II
Author

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

QFabian
MVP
MVP

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

Greetings!! Fabián Quezada (QFabian)
did it work for you? give like and mark the solution as accepted.
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)))