Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
AmritaOS
Helper I
Helper I

Network Days Error in Power Query

Hello,

i am trying to calculate network days from two columns of dates. 

StartDate             EndDate

02/02/202102/02/2021
02/02/202103/02/2021
02/02/202108/02/2021
10/03/202119/03/2021
null20/03/2021
02/02/2021null
08/02/202102/02/2021

 

conditional logic:

1. take into account weekends and PublicHolidays1

2. If either of the values are null to return a null

3. if the start date is greater than the created date to return a null

 

here is the function i am using: kindly provided by @Jimmy801 

 

(StartDate as date, EndDate as date) as number =>

let
IntStartDate = if StartDate = null then null else StartDate ,
IntEndDate = if EndDate = null then null else EndDate ,
ListDates = List.Dates(IntStartDate, Number.From(IntEndDate - IntStartDate), #duration(1, 0, 0, 0)),
RemoveWeekends = List.Select(ListDates, each Date.DayOfWeek(_, Day.Monday) < 5),
RemoveHolidays = List.RemoveItems(RemoveWeekends, PublicHolidays1),
CountDays = List.Count(RemoveHolidays)

in

if IntStartDate > IntEndDate then null else CountDays

 

i am getting this error and am lost as to how to fix it.

Expression.Error: We cannot convert a value of type Table to type List.
Details:
Value=[Table]
Type=[Type]

 

thanks

Amrita

 

1 ACCEPTED SOLUTION

HI Jimmy, i used the TRY and removed the error so all good. thanks!

View solution in original post

5 REPLIES 5
mahoneypat
Microsoft Employee
Microsoft Employee

I suspect your PublicHolidays1 query is in table form, and a list is expected in the function.  Is that the case?  If so, you can replace it with PublicHolidays1[ColumnName], which will pull that single column (replace with actual name of it) from the PublicHolidays1 table as a list.

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


hi pat yes publicholidays1 i have changed the code and its working great - except - i am now gettign this error where the value should return as null

 

Expression.Error: We cannot convert the value null to type Date.
Details:
Value=
Type=[Type]

Hi Amrita, 

 

I am also getting the same error. Did you manage to resolve it?

Hello @AmritaOS 

 

do you still have problems?

 

BR

 

Jimmy

HI Jimmy, i used the TRY and removed the error so all good. thanks!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors