Skip to main content
Announcements
YOUR OPINION MATTERS! Please take the Qlik Experience survey you received via email. Survey ends June 14.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

¿How to count Saturdays in date range?

Hi there,

I need your help to solve my issue, i need to count saturdays in date range:

I have a field with date (Format: DD/MM/YYYY hh:mm:ss) and i make filters in diferents range but i need only count how many saturdays exist into this range selected (the range is variable).

Thanks for all!.

Thanks in advance.

1 Solution

Accepted Solutions
swuehl
MVP
MVP

You have changed the system variable FirstWeekDay, which influences Weekday() function.

You can correct this like

Div(WEEKDAY(Min([Creation Time])-6,0)+1-Min([Creation Time])+Max([Creation Time]),7)

View solution in original post

17 Replies
swuehl
MVP
MVP

Maybe like shown here

Re: Count of Saturday in whole month

=Div(WEEKDAY(Min(DateField)-6)+1-Min(DateField)+Max(DateField),7)

florentina_doga
Partner - Creator III
Partner - Creator III

in script;

aa:

load *,

WeekDay(data) as week_name;

load * inline [data

1/1/2016

2/1/2016

3/1/2016

4/1/2016];

and in interface

count(distinct if(week_name='Sat',data))

Not applicable
Author

Does not work!

MK_QSL
MVP
MVP

Div(Date2-Date1,7) + (WeekDay(Date1)<=5)*(WeekDay(Date2)>=5)

swuehl
MVP
MVP

'Does not work' is not a really helpful issue description.

Do you get an error, no value, wrong value?

(I assume you have replaced DateField with the field name of your date field).

See attached a sample QVW.

florentina_doga
Partner - Creator III
Partner - Creator III

see this attach

Not applicable
Author

Qlik Sense Desktop_2.jpg

Does not work, this formule is counting 1 with any saturdays selected.

tamilarasu
Champion
Champion

Maybe try,

Count(If(Weekday(DateField)='Sat',1))

smirkinaa
Contributor III
Contributor III

Hi, I suggest to use additional field with number of weekday, which we have to add in the load script. And than you can use expression like this "Count({<WeekDayField = {5}>} DISTINCT DateField)". We have to use integer values in DateField. That's why we should use transformation for it: Floor(BaseDateField).