Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Highlighted
Not applicable

Counting number of work days based off Date field selection

Hello all,

I am trying to count the work days based on the months that are selected. My date values consist of the last day of every month. Currently I am doing the following:

(If(WildMatch(GetFieldSelections(Date), '1/312017'), networkdays(1/1/2017, 1/31/2017), 0)) + 2/28/2017 + ... + 12/31/2017

I am only getting 0 returned. I believe the problem is getfieldselections is returning the date in a different format. I do not know what it is though. Any help would be greatly appreciated. Thank you in advance.

1 Solution

Accepted Solutions
Not applicable

Re: Counting number of work days based off Date field selection

I have solved my issue by using SubStringCount rather than WildMatch.

((If(SubStringCount(GetFieldSelections(Date), '1/31') > 0, netWorkDays('1/1/2017', '1/31/2017'), 0))

+ (If(SubStringCount(GetFieldSelections(Date), '2/28') > 0, netWorkDays('2/1/2017', '2/28/2017'), 0))

+ (If(SubStringCount(GetFieldSelections(Date), '3/31') > 0, netWorkDays('3/1/2017', '3/31/2017'), 0))

+ (If(SubStringCount(GetFieldSelections(Date), '4/30') > 0, netWorkDays('4/1/2017', '4/30/2017'), 0))

+ (If(SubStringCount(GetFieldSelections(Date), '5/31') > 0, netWorkDays('5/1/2017', '5/31/2017'), 0))

+ (If(SubStringCount(GetFieldSelections(Date), '6/30') > 0, netWorkDays('6/1/2017', '6/30/2017'), 0))

+ (If(SubStringCount(GetFieldSelections(Date), '7/31') > 0, netWorkDays('7/1/2017', '7/31/2017'), 0))

+ (If(SubStringCount(GetFieldSelections(Date), '8/31') > 0, netWorkDays('8/1/2017', '8/31/2017'), 0))

+ (If(SubStringCount(GetFieldSelections(Date), '9/30') > 0, netWorkDays('9/1/2017', '9/30/2017'), 0))

+ (If(SubStringCount(GetFieldSelections(Date), '10/31') > 0, netWorkDays('10/1/2017', '10/31/2017'), 0))

+ (If(SubStringCount(GetFieldSelections(Date), '11/30') > 0, netWorkDays('11/1/2017', '11/30/2017'), 0))

+ (If(SubStringCount(GetFieldSelections(Date), '12/31') > 0, netWorkDays('12/1/2017', '12/31/2017'), 0)))

View solution in original post

1 Reply
Not applicable

Re: Counting number of work days based off Date field selection

I have solved my issue by using SubStringCount rather than WildMatch.

((If(SubStringCount(GetFieldSelections(Date), '1/31') > 0, netWorkDays('1/1/2017', '1/31/2017'), 0))

+ (If(SubStringCount(GetFieldSelections(Date), '2/28') > 0, netWorkDays('2/1/2017', '2/28/2017'), 0))

+ (If(SubStringCount(GetFieldSelections(Date), '3/31') > 0, netWorkDays('3/1/2017', '3/31/2017'), 0))

+ (If(SubStringCount(GetFieldSelections(Date), '4/30') > 0, netWorkDays('4/1/2017', '4/30/2017'), 0))

+ (If(SubStringCount(GetFieldSelections(Date), '5/31') > 0, netWorkDays('5/1/2017', '5/31/2017'), 0))

+ (If(SubStringCount(GetFieldSelections(Date), '6/30') > 0, netWorkDays('6/1/2017', '6/30/2017'), 0))

+ (If(SubStringCount(GetFieldSelections(Date), '7/31') > 0, netWorkDays('7/1/2017', '7/31/2017'), 0))

+ (If(SubStringCount(GetFieldSelections(Date), '8/31') > 0, netWorkDays('8/1/2017', '8/31/2017'), 0))

+ (If(SubStringCount(GetFieldSelections(Date), '9/30') > 0, netWorkDays('9/1/2017', '9/30/2017'), 0))

+ (If(SubStringCount(GetFieldSelections(Date), '10/31') > 0, netWorkDays('10/1/2017', '10/31/2017'), 0))

+ (If(SubStringCount(GetFieldSelections(Date), '11/30') > 0, netWorkDays('11/1/2017', '11/30/2017'), 0))

+ (If(SubStringCount(GetFieldSelections(Date), '12/31') > 0, netWorkDays('12/1/2017', '12/31/2017'), 0)))

View solution in original post