powerpivot - Calculate the number of business days between two dates in power pivot -


i looking formula calculate number of weekdays/business days between 2 dates in power pivot.

i same in t-sql using following query

datediff(dd, date1, getdate()) - (datediff(wk, date1, getdate()) * 2) -             case when datepart(dw, date1) = 1 1 else 0 end +             case when datepart(dw, getdate()) = 1 1 else 0 end end  

i looking similar query in powerpivot.

first need create table of dates. in issue, , enable use many other time intelligence functions. can create manually or using

calendardate | month key | month name | quarter name | year ----------------------------------------------------------- 1/1/2014     | 1.00      | jan        | q1           | 2014 1/2/2014     | 1.00      | jan        | q1           | 2014 ... 2/1/2014     | 2.00      | feb        | q1           | 2014 .... 8/1/2014     | 8.00      | aug        | q3           | 2014 .. 9/2/2014     | 9.00      | sep        | q3           | 2014 .. 12/16/2014   | 12.00     | dec        | q4           | 2014 

in dates table can create calculated column determines if each day weekday. call column isweekday

=switch(weekday([calendardate]),7,false(),1,false(),true()) 

the switch statement return false if day of week 7th or 1st day of week (saturday/sunday)

now in table contains transactions can create new calculated column called number of weekdays.

=calculate(counta(dates[isweekday]),            datesbetween(dates[calendardate],                          transactiontable[date1],                         transactiontable[date2]                        )           ) 

here 2 articles recommend related approach.


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -