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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Count number of Monday's, Tuesday's ... from a StartDate to selected Year/Month

I'm looking for a way of calculating the number of Monday's, Tuesday's ... etc from a StartDate until a certain selected year/month.

Does anyone have idea's how to do something like this??

e.g.

Callnr, StartDate

1, 1-9-2009
2, 4-9-2009
3,19-8-2010

Selected YEAR / MONTH = 2010 / September

In this case I need to calculate the number of days between the StartDate and the Year/Month selections. This is not that hard ...

But what I really need is how many of each Weekday is between the StartDate and the Year/Month selection.

Anyone got suggestions??

thx

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

Here's a script solution. It builds two new tables. One matches the StartDate to every date between then and today, and has a day of week field in it. One matches an AsOfDate to every date between then and a year ago (or as early as your data goes). The chart is then a simple pivot table:

dimension 1 (left) = Callnr
dimension 2 (left) = StartDate
dimension 3 (top) = DayOfWeek
expression = count(Date)

An amusing way to see it working is to select an AsOfDate, and then use the up and down arrow keys move the selected date forward or backward, and watch it increment and decrement the column for that weekday.

View solution in original post

5 Replies
syed_muzammil
Partner - Creator II
Partner - Creator II

Hi,

You can use the function weekday(Date) during load. This will get you the weekday numer and inthe front end youcan give count(weekday field) where weekday feild = 0 (for Monday)

Regards,

Syed.

Anonymous
Not applicable
Author

At the backend I'm already loading the weekday ... but still got some issues because this is in a separate table which is not connected to the Call table containing the startdate

Think I should do some tricks with expressions on the frontend to solve this ... which will do something with the summing of the weekday ...

Thx

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

This is a sample that does what I think you want.

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
johnw
Champion III
Champion III

Here's a script solution. It builds two new tables. One matches the StartDate to every date between then and today, and has a day of week field in it. One matches an AsOfDate to every date between then and a year ago (or as early as your data goes). The chart is then a simple pivot table:

dimension 1 (left) = Callnr
dimension 2 (left) = StartDate
dimension 3 (top) = DayOfWeek
expression = count(Date)

An amusing way to see it working is to select an AsOfDate, and then use the up and down arrow keys move the selected date forward or backward, and watch it increment and decrement the column for that weekday.

Anonymous
Not applicable
Author

This is exactly what I was looking for ... thx 😉

I'm not really into the while looping yet ... so I'm learning each day