
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to count no of Sundays between two dates in qliksense
How to count no of Sundays between two dates in qliksense
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@charu16aug If you want to do it in backend I am assuming that you have StartDate and EndDate in your data. You can try below
let vWeekDayNumber= 6; //0-Mon,1-Tue,2-Wed....
set NoOfSunday = 'Div(num(WeekDay($1-($(vWeekDayNumber)+1),0))+1-$1+$2,7)';
Data:
Load *,
$(NoOfSunday(StartDate,EndDate)) as NoOfSunday
Inline [
StartDate,EndDate
01/03/2023, 01/05/2023
01/04/2023, 01/05/2023 ];

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
You have to create WeekendFlag in your script:
if(WeekDay(yourdatefield)='Sun',1,0) as WeekendFlag
And in your frontend use the below expression
count({1<WeekendFlag={'1'}, Date={">=$(=your min date)<=$(=your max date)"}>}WeekendFlag)
Hope this helps,
help user find answers ! don't forget to mark a solution that work for you and click the like button!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i have to perform this on backend

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have to add
WeekDay(your date field) as WeekDay;
in master calendar.
Then insert
if(WeekDay(yourdatefield)='Sun',1,0) as WeekendFlag,
in your table.
These task will be in your backend

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
then how to count no. if Sundays between two dates in the backend?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
count({1<WeekendFlag={'1'}, Date={">=$(=your min date)<=$(=your max date)"}>}WeekendFlag)
In frontend this expression will give you the count of Sundays

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
this is an intermediate step, so i want to count this in backend only

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@charu16aug If you want to do it in backend I am assuming that you have StartDate and EndDate in your data. You can try below
let vWeekDayNumber= 6; //0-Mon,1-Tue,2-Wed....
set NoOfSunday = 'Div(num(WeekDay($1-($(vWeekDayNumber)+1),0))+1-$1+$2,7)';
Data:
Load *,
$(NoOfSunday(StartDate,EndDate)) as NoOfSunday
Inline [
StartDate,EndDate
01/03/2023, 01/05/2023
01/04/2023, 01/05/2023 ];

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks @Kushal_Chawda


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Div(EndDate-StartDate+WeekDay(StartDate)+1,7)
- Tags:
- excludesundays
