Count specific weekdays between two dates / date range

Hi @Vytenis :slight_smile: !

I might have a little something for you there for both your questions :slight_smile:

Using this post as a base : Calculate all months in a range (20x faster) , I ended up with this formula to count Sundays (weekday n°1) in a date range :
(for some ease, I created a field Today in my test doc, but the formula works with Today() too :wink: and as CountIf() is a slow formula which can lead to performance problem, I didn’t use it :wink: )

Sequence(thisRow.[Date X],thisRow.Today).FormulaMap(ToDate(CurrentValue).Weekday()).Filter(CurrentValue=1).Count()

Therefore, for counting Saturdays and Sundays the formula is :
Sequence(thisRow.[Date X],thisRow.Today).FormulaMap(ToDate(CurrentValue).Weekday()).Filter(CurrentValue=1 OR CurrentValue=7).Count()

Which means that you can count any weekdays simply by changing the number of the CurrentValue in the Filter() :slight_smile: (there’s an example with counting Mondays, Wednesdays and Fridays in the test doc :wink: )

The fields Dates between Today & Date X [List] and Dates between Today & Date X : Weekdays [List] are just there for visual help :wink:

2 Likes