Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Number of days excluding friday

Hi,

I need to calculate the number of days between the two dates excluding the Fridays.

For Ex,

1.

Date1 : 01-Jun-2014

Date2 : 10-Jun-2014

No .of days =9, because 6th Jun 2014 is Friday

2.

Date1 : 01-Jun-2014

Date2 : 20-Jun-2014

No .of days =17, because 6th,13th and 20th Jun 2014 are Fridays.

Thanks in Advance.

Tags (3)
5 Replies

Re: Number of days excluding friday

In your load script create a WeekDay field and then use in expression like

Load 

Weekday(DateField) as Weekday

From Loaction;

And in expression use it like

=Count( {<Weekday -= {'Fri'} >}  YourDatefieldHere)

By doing this calculation from your data this expression exclude only friday dates and count rest of the dates

MVP
MVP

Re: Number of days excluding friday

Something like:

=(EndDate-StartDate-Num(WeekDay(StartDate))-Floor(EndDate-StartDate-Num(WeekDay(StartDate))/7-If(Num(WeekDay(StartDate)<5,1,0)

This '5' stands for Saturday which may vary based on your time setting.

I feel there should be a simpler solution.

Not applicable

Re: Number of days excluding friday

Hi Gopinathan

Please find attachment hope this will help you

-Rajendra

Re: Number of days excluding friday

Hi you can even try like this

LOAD

     DateFieldName,

     If(WeekDay(DateFieldName) = 'Fri' , 1, 0) AS WeekEndFlag

FROM ABC;

Now in setanalysis expression use

=Count({<WeekEndFlag = {0}>} DateFieldName)

Regards

ASHFAQ

Not applicable

Re: Re: Number of days excluding friday

soln.png

Community Browser