Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
ananyaghosh
Creator III
Creator III

How can I calculate the number of wednesday exists in a date range?

!Hi,

I have created a date filed and assign the value to a variable vDate and I have a date range also and assign the value to a variable vRANGE. Now if the use select vDate as 24/1/2018 and range as 9, the I have to calculate the number of Wednesday which is actually the creation date in that range.

SO if vDate is 24/1/2018 and vRange is 9, the the date range is 15/1/2018 To 24/1/2018 and I need to calculate how many weekday means Sunday, Monday, Tuesday, Wednesday, Thrusday, Friday and Saturday is in between in that date range?

I have used the below set analysis for this purpose:

count({$<CREATION_DATE={">$(=(Date(Date#('$(vDATE)','M/DD/YYYY')-if('$(vRANGE)'='0','1','$(vRANGE)'))))<=$(vDATE)"}>}weekday(CREATION_DATE))

but it gives me nothing.

so any idea will be appreciated.

Thanks,

Sandip Ghosh

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Have a look at the Valueloop() parameter. They are defining a different date range in the example, Today() to Today()+9 days ahead.

You may adapt to your needs, like

=SubstringCount(concat( (weekday(date(ValueLoop(num(Today())-8,num(Today()),1)))) ,','),'Wed')

View solution in original post

23 Replies
YoussefBelloum
Champion
Champion

Hi,

use this set analysis part:

your_date_field={"=weekday(your_date_field)=2"}

ananyaghosh
Creator III
Creator III
Author

I can't understand your point. Please clarify it.

YoussefBelloum
Champion
Champion

on the title of your thread it is said that you want to: calculate the number of Wednesday that exist on range date.

my suggestion is to add this to you expression:

your_date_field={"=weekday(your_date_field)=2"} ==> to calculate the number of Wednesdays on your Date range.

Peter_Cammaert
Partner - Champion III
Partner - Champion III

If want to know how many times the weekday of vDate occurs in a preceding period of vRange days and including vDate itself, then that number can be calculated simply as:

=floor(vRange/7)+1

e.g. vDate=24/1/2018 and vRange=9 means that between 15/1/2018 and 24/1/2018 there are floor(9/7)+1 = 2 Wednesdays.

BTW this works in both directions.

ananyaghosh
Creator III
Creator III
Author

Hi,

YOur calculations works for me, so what will be the calculation for

1. Saturday

2. Sunday,

3. Monday

4.Tuesday

5. thursday

and Friday also?

Please help me in those case also. I am looking forward your reply.

ananyaghosh
Creator III
Creator III
Author

Hi,

Please help for this purpose as I am looking forward to your reply.

Thanks,

Sandip Ghosh

qv_testing
Specialist II
Specialist II

Try this Expression

=count({1<CalendarWeek={'Wed'},CalendarDate={">=$(=Date#('01-01-2000','DD/MM/YYYY'))<=$(=Date#('31/01/2000','DD-MM-YYYY'))"}>}CalendarDate).

ananyaghosh
Creator III
Creator III
Author

Hi,

I am using the below set expression:

=count({$<Week_Day={'Wed'},

CREATION_DATE={">$(=(Date(Date#('$(vDATE)','M/DD/YYYY')-if('$(vRANGE)'='0','1','$(vRANGE)'))))<=$(=Date#('$(vDATE)','M/DD/YYYY'))"}>}CREATION_DATE)


where I have to count the the number of Wednesday in a specific date range and vDATE is the variable name where I have put the date value and vRANGE is the date range which is actually is a numeric number.


But this is not working for me. Please help me in this case.

qv_testing
Specialist II
Specialist II

Try this,

=count({<Week_day={'Wed'}, [Last Login Time]={">=$(=date($(vMinLastlogin)))<=$(=date($(vMaxLastlogin)))"}>}DISTINCT [Last Login Time])

Change Your variables..

Hope this works...!