PowerBI - 创建网络国际日作为衡量标准
PowerBI - Creating Network International Days as a Measure
我有一个要求,其中我有 2 Tables,Table 1 - DateTable 和 Table 2 - MyTable.
我正在尝试计算类似于我们在 Excel 中所做的网络国际天数。
Note : My 2 Tables are not connected as they don't have a key
DateTable has the Holidays in the column Holiday.
MyTable has my date in the column SubmittedDate.
你会如何解决这个问题并创建一个度量来计算国际联网日?
请求的架构:
MyTable
Name RequestID SubmittedDate ExpectedResult
XABI 209874 25/7/2017 3
DateTable
Holidays Day Reason
28/7/2017 Friday blabla
27/7/2017 Thursday blaalala
ExpectedResult 是我要计算的 - 它是 3,因为只有 3 个工作日,即 25/7、26/7、31/7(今天)。
28/7 和 27/7 是公司假期,29/7、30/7 是周末假期。
请分享您的想法。
holidays
table(在你的例子中是DateTable
):
date
2017-01-02
calendar
table(引入):
date
2017-01-01
2017-01-02
2017-01-03
2017-01-04
2017-01-05
2017-01-06
2017-01-07
...
data
table(在你的例子中是MyTable
):
date
2017-01-01
2017-01-03
将计算列添加到 calendar
table:
isworkingday =
var isweekend = if(WEEKDAY(calendar[date])>5, 1, 0)
var isholiday = if(CONTAINS(holidays, holidays[date], calendar[date]), 1, 0)
return if(AND(isweekend=0, isholiday=0), 1, 0)
将计算列添加到 data
table:
workingDaysPassed =
var curr = data[date]
return calculate(sum(calendar[isworkingday]),
and(calendar[date]>=curr,
calendar[date]<=today()),
all(data))
workingDaysPassed
应该是你的 ExpectedResult
,只要你填写 calendar
table:
date, isworkingday, workingDaysPassed
2017-01-01, 1, 4
2017-01-02, 0, 3
2017-01-03, 1, 3
2017-01-04, 1, 2
2017-01-05, 1, 1
2017-01-06, 0, 0
2017-01-07, 0, 0
我有一个要求,其中我有 2 Tables,Table 1 - DateTable 和 Table 2 - MyTable.
我正在尝试计算类似于我们在 Excel 中所做的网络国际天数。
Note : My 2 Tables are not connected as they don't have a key
DateTable has the Holidays in the column Holiday.
MyTable has my date in the column SubmittedDate.
你会如何解决这个问题并创建一个度量来计算国际联网日?
请求的架构:
MyTable
Name RequestID SubmittedDate ExpectedResult
XABI 209874 25/7/2017 3
DateTable
Holidays Day Reason
28/7/2017 Friday blabla
27/7/2017 Thursday blaalala
ExpectedResult 是我要计算的 - 它是 3,因为只有 3 个工作日,即 25/7、26/7、31/7(今天)。
28/7 和 27/7 是公司假期,29/7、30/7 是周末假期。
请分享您的想法。
holidays
table(在你的例子中是DateTable
):
date
2017-01-02
calendar
table(引入):
date
2017-01-01
2017-01-02
2017-01-03
2017-01-04
2017-01-05
2017-01-06
2017-01-07
...
data
table(在你的例子中是MyTable
):
date
2017-01-01
2017-01-03
将计算列添加到 calendar
table:
isworkingday =
var isweekend = if(WEEKDAY(calendar[date])>5, 1, 0)
var isholiday = if(CONTAINS(holidays, holidays[date], calendar[date]), 1, 0)
return if(AND(isweekend=0, isholiday=0), 1, 0)
将计算列添加到 data
table:
workingDaysPassed =
var curr = data[date]
return calculate(sum(calendar[isworkingday]),
and(calendar[date]>=curr,
calendar[date]<=today()),
all(data))
workingDaysPassed
应该是你的 ExpectedResult
,只要你填写 calendar
table:
date, isworkingday, workingDaysPassed
2017-01-01, 1, 4
2017-01-02, 0, 3
2017-01-03, 1, 3
2017-01-04, 1, 2
2017-01-05, 1, 1
2017-01-06, 0, 0
2017-01-07, 0, 0