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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
nicalbert
Partner - Contributor III
Partner - Contributor III

Counting values using a date in if statement

Hello everyone,

I'm trying to count the number of items from type XYZ that were created on a given day of the week. So basically, my expression should (?) have 2 "if" condition. So, let's say that I'm only counting the items of type 13 that were made on Mondays, the expression would look like:

          count(if(ItemType='13',if(weekDay(ItemCreatedDate = 'Mon'), ItemId)))

Now, this obviously does not work... Can anyone provide me some help?

Thanks,

Nic

1 Solution

Accepted Solutions
pradosh_thakur
Master II
Master II

count(if(ItemType='13' and weekDay(ItemCreatedDate) = 'Mon', ItemId))

or

sum(if(ItemType='13' and weekDay(ItemCreatedDate) = 'Mon', 1,0))

you may need to wrap expression in some aggr() function if using it in a text box .

Learning never stops.

View solution in original post

4 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Try this.

count(if(ItemType='13' and weekDay(ItemCreatedDate) = 'Mon', ItemId))


Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
pradosh_thakur
Master II
Master II

count(if(ItemType='13' and weekDay(ItemCreatedDate) = 'Mon', ItemId))

or

sum(if(ItemType='13' and weekDay(ItemCreatedDate) = 'Mon', 1,0))

you may need to wrap expression in some aggr() function if using it in a text box .

Learning never stops.
nicalbert
Partner - Contributor III
Partner - Contributor III
Author

This one worked perfectly:

count(if(ItemType='13' and weekDay(ItemCreatedDate) = 'Mon', ItemId))


Thank you very much to you both, that was really fast and accurate!

Nic

hjimenez25
Partner - Contributor II
Partner - Contributor II

Hi,

Try this too, you decide which expression is better for you:

count({<ItemType={13}>} if(WeekDay(ItemCreatedDate)='Mon',ItemId,null()))

Regards.