Forum Discussion

LarsEva's avatar
LarsEva
New Member
2 years ago
Solved

Custom Function: Networkdays load rows very slowly

Hi, i'm new to using power query and i've been trying to calculate the networkdays of 2 columns in my table. I am using a custom function i found on the web (which i think everyone is using) That us...
  • Vijay_A_Verma's avatar
    2 years ago

    Use following formula in a custom column to calculate Networkdays. You will need to replace Start and End

    List.Count(List.Select(List.Dates([Start], Duration.Days([End]-[Start])+1, #duration(1,0,0,0)), each Date.DayOfWeek(_,1)<5))

     If you want a very fast way, then insert this step. Replace #"Changed Type" with your previous step and of course, Start and End.

    = Table.FromRecords(List.Transform(Table.ToRecords(#"Changed Type"), (x)=> Record.AddField(x, "Networkdays", List.Count(List.Select(List.Dates(x[Start], Duration.Days(x[End]-x[Start])+1, #duration(1,0,0,0)), each Date.DayOfWeek(_,1)<5)))))