Calculating average NETWORK days Power BI

吃可爱长大的小学妹 提交于 2019-12-11 13:48:50

问题


I've been reading various threads and guides to performing a 'NETWORKDAYS' style calculation in Power BI but struggling to make it work.

I have a table like this:

Team |  Meeting    |  Report
aaa  | 1/1/2018    |  9/1/2018
aaa  | 1/1/2018    |  7/1/2018
bbb  | 1/1/2018    |  1/2/2018
bbb  | 1/1/2018    | 
ccc  | 1/1/2018    |  3/3/2018
aaa  | 1/1/2018    | 

And I want to return the average days without weekends and holidays, something like this:

Team | average
aaa  | 5 (10/2)
bbb  | 23 (45/1)
ccc  | 45 (45/1)

I have this function, which seems to work albeit clunkily, but I don't know how to remove the non-weekdays from the Date table:

AVERAGEX(FILTER(Planning,NOT(ISBLANK(Planning Actual_FinalReport]))),
    (COUNTROWS(DATESBETWEEN(DateTable[Date],
    Planning[Actual_ClosingMeeting],Planning [Actual_FinalReport]))
))

Where DateTable is:

Date    | Weekday
5/1/2018| 1
6/1/2018| 0
7/1/2018| 0

and so on...

Essentially, I want to iterate over Planning (filtering out blanks in [Report]) and count the dates between Meeting and Report from the Dates table, filtered by Weekday = 1. It's the syntax to link the tables I think I'm struggling with.


回答1:


Modifying your formula a bit, how about something like this?

Average = AVERAGEX(
              FILTER(Planning,
                  NOT(ISBLANK(Planning[Actual_FinalReport]))),
              COUNTROWS(
                  FILTER(DateTable,
                      DateTable[Date] IN DATESBETWEEN(
                                             DateTable[Date],
                                             Planning[Actual_ClosingMeeting],
                                             Planning[Actual_FinalReport]) &&
                      DateTable[Weekday] = 1)))

I'm adding the Weekday filter at the end.



来源:https://stackoverflow.com/questions/49324352/calculating-average-network-days-power-bi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!