• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to calculate total days using networdays.intl with condition state list holiday

rafiz87

New Member
facing the issue to calculation total days using networdays.intl with condition state list holiday. got error and incorrect result.
Attached the file for reference and guideline.
Please help
 

Attachments

  • Files - calculate total days.xlsx
    9.8 KB · Views: 3
Maybe this works
=NETWORKDAYS.INTL(C5;D5;XLOOKUP(B5;Holiday!$G$2:$G$8;Holiday!$F$2:$F$8);FILTER(Holiday!$B$2:$B$7;Holiday!$A$2:$A$7='Total Days'!A5;0))
 

Attachments

  • Files - calculate total days.xlsx
    11.4 KB · Views: 6
Maybe this works
=NETWORKDAYS.INTL(C5;D5;XLOOKUP(B5;Holiday!$G$2:$G$8;Holiday!$F$2:$F$8);FILTER(Holiday!$B$2:$B$7;Holiday!$A$2:$A$7='Total Days'!A5;0))
Thank you. instead using xlookup and filter, do you have other method? currently i use excel 2016. i try use xlookup and filter cannot work
 
If you keep the set-up of the holidays grouped per state, this seems to work:
=NETWORKDAYS.INTL(C2;D2;VLOOKUP(B2;Holiday!$G$2:$H$8;2;FALSE);IFNA(OFFSET(Holiday!A1;MATCH(A2;Holiday!$A$2:$A$7;0);1;COUNTIF(Holiday!$A$2:$A$7;A2));0))
 

Attachments

  • Files - calculate total days(1).xlsx
    11.6 KB · Views: 4
If you keep the set-up of the holidays grouped per state, this seems to work:
=NETWORKDAYS.INTL(C2;D2;VLOOKUP(B2;Holiday!$G$2:$H$8;2;FALSE);IFNA(OFFSET(Holiday!A1;MATCH(A2;Holiday!$A$2:$A$7;0);1;COUNTIF(Holiday!$A$2:$A$7;A2));0))
if use this formula let say from start date to end date after holiday or before holiday, Is it this formula will calculate also for countif holiday too? supposedly did not countif in list holiday right? please correct me if i wrong
 
I see I did a mistake in the offset formula. The starting position needs to be an absolute reference OFFSET(Holiday!$A$1

OFFSET can return a array. In the example of Melaka it returns 2 dates 5/01/2024 and 6/01/2024. Because we have 2x Melaka in the list of hoilidays. Hence the countif used. These days are used in the argument holidays of NETWORKDAYS.INTL function. That function corrects the number of working days taking into account the list of holidays. So if the start and end date are both before or after the holidays will have no effect on the calculation. In that scenario the holidays are simply omitted.

I can advise you to use the formula auditor to learn how the formula works.
1709469248468.png
After pressing evaluate a couple of times, you will see the following. It also shows you how the formula is calculated.
1709469286722.png
 
Last edited:
I see I did a mistake in the offset formula. The starting position needs to be an absolute reference OFFSET(Holiday!$A$1

OFFSET can return a array. In the example of Melaka it returns 2 dates 5/01/2023 and 6/01/2024. Because we have 2x Melaka in the list of hoilidays. Hence the countif used. These days are used in the argument holidays of NETWORKDAYS.INTL function. That function corrects the number of working days taking into account the list of holidays. So if the start and end date are both before or after the holidays will have no effect on the calculation. In that scenario the holidays are simply omitted.
oh i see. may i know, which part need to use for OFFSET(Holiday!$A$1 into this formula ?
=NETWORKDAYS.INTL(C2;D2;VLOOKUP(B2;Holiday!$G$2:$H$8;2;FALSE);IFNA(OFFSET(Holiday!A1;MATCH(A2;Holiday!$A$2:$A$7;0);1;COUNTIF(Holiday!$A$2:$A$7;A2));0))
 
=NETWORKDAYS.INTL(C2;D2;VLOOKUP(B2;Holiday!$G$2:$H$8;2;FALSE);IFNA(OFFSET(Holiday!$A$1;MATCH(A2;Holiday!$A$2:$A$7;0);1;COUNTIF(Holiday!$A$2:$A$7;A2));0))
 
I see I did a mistake in the offset formula. The starting position needs to be an absolute reference OFFSET(Holiday!$A$1

OFFSET can return a array. In the example of Melaka it returns 2 dates 5/01/2024 and 6/01/2024. Because we have 2x Melaka in the list of hoilidays. Hence the countif used. These days are used in the argument holidays of NETWORKDAYS.INTL function. That function corrects the number of working days taking into account the list of holidays. So if the start and end date are both before or after the holidays will have no effect on the calculation. In that scenario the holidays are simply omitted.

I can advise you to use the formula auditor to learn how the formula works.
View attachment 86613
After pressing evaluate a couple of times, you will see the following. It also shows you how the formula is calculated.
View attachment 86614
Just to ask, what tool you use ya? excel file or WPS? i check in WPS this tab formula have it.. but in my excel evaluate formula did not active

1709469769202.png
 
Did you select the cell, with the formula? Evaluate is on the ribbon since many versions prior to Excel 2016.
Just to ask, what tool you use ya? excel file or WPS? i check in WPS this tab formula have it.. but in my excel evaluate formula did not active

View attachment 86615
For the error, might it be you have to use a comma "," as argument separator in the formula where I have semi-colon ";"?

See #4, you can open that file. Only correct the formula as in #8
 
Did you select the cell, with the formula? Evaluate is on the ribbon since many versions prior to Excel 2016.

For the error, might it be you have to use a comma "," as argument separator in the formula where I have semi-colon ";"?

See #4, you can open that file. Only correct the formula as in #8
Its works. thank you for your assistance. can this formula to use in power query, dax (power bi)?
 
I do not know of any networkdays-alike function in Power Query. Having said this, with some creativity it can be created with list operators for sure. Google it and you may find some custom made functions by MVP or Power Query experts.
DAX knows the function and as far as arguments go is quite similar to Excel's function. However DAX looks simple at first glance, I can tell you it is not that easy to truly master. You can't simply replicate any excel formula in DAX.
 
I do not know of any networkdays-alike function in Power Query. Having said this, with some creativity it can be created with list operators for sure. Google it and you may find some custom made functions by MVP or Power Query experts.
DAX knows the function and as far as arguments go is quite similar to Excel's function. However DAX looks simple at first glance, I can tell you it is not that easy to truly master. You can't simply replicate any excel formula in DAX.
Thank you for your advice and guidance.
 
Back
Top