如何显示 运行 由每个实例的间隔和时间定义的总时间
How to show running totals of time defined by an interval and time per instance
我有一个 table 定义了执行客户端服务的时间间隔。还定义了每次执行服务时的分配持续时间。
像这样:
以上table是将为部分客户执行的服务示例。
对于ClientId:1,信息应该读作:
Client 1 has ordered ServiceType:100 to be performed for 1.5hrs every
third day, starting 2020-01-01 and until further notice.
For Client:4 信息应读作:
Client 4 has ordered ServiceType:200 to be performed for 4 hours every
4th day, starting 2020-01-02 and until further notice.
我的老板现在要我制作一张图表,显示按日期为任何服务花费的总小时数。
2020-01-01 和 2020-01-31 之间的日期范围应该创建以下理论数据集来显示:
(我只需要显示日期和总时间,其他列可以忽略)
然后将上面的数据显示在图表中,如下所示:
我的问题是如何创建一个可以计算总时间的度量,给定报告中当前选择的日期过滤器,并且可以用来创建上图。
非常感谢任何帮助!
亲切的问候,
彼得
您可以使用 M (Power Query) 实现此目的,我的解决方案不会像 "IntervalType" 那样管理您要求的所有详细信息,但允许您在输入标准化后获取所需的行。
下面的 M 脚本将满足以下要求(您可以使用高级编辑器查看完整脚本):
- 所有行和使用的指标共享相同的度量单位,即:天
{here you have already loaded your table}
/*Calculate the difference between the 2 dates in days*/
/*note that if the end date is 9999-12-31 you may want to set an upper limit*/
#"Added Custom" = Table.AddColumn(#"Changed Type", "DaysInterval", each Duration.Days([EndDate]- [StartDate])),
/*Calculate how many times the service will be performed in the calculated interval*/
#"Added Custom1" = Table.AddColumn(#"Added Custom", "IntervalOccurence", each Number.RoundDown([DaysInterval]/[Interval])),
/*Use what has been calculated so far to create a list of dates for each row*/
#"Added Custom2" = Table.AddColumn(#"Added Custom1", "ListDates", each List.Dates([StartDate],[IntervalOccurence],#duration([Interval], 0, 0, 0))),
/*Expand the list to rows (using the UI click on the arrows in the column header)*/
#"Expanded ListDates" = Table.ExpandListColumn(#"Added Custom2", "ListDates")
之后,您只需删除不需要的列。
我有一个 table 定义了执行客户端服务的时间间隔。还定义了每次执行服务时的分配持续时间。
像这样:
以上table是将为部分客户执行的服务示例。
对于ClientId:1,信息应该读作:
Client 1 has ordered ServiceType:100 to be performed for 1.5hrs every third day, starting 2020-01-01 and until further notice.
For Client:4 信息应读作:
Client 4 has ordered ServiceType:200 to be performed for 4 hours every 4th day, starting 2020-01-02 and until further notice.
我的老板现在要我制作一张图表,显示按日期为任何服务花费的总小时数。
2020-01-01 和 2020-01-31 之间的日期范围应该创建以下理论数据集来显示:
(我只需要显示日期和总时间,其他列可以忽略)
然后将上面的数据显示在图表中,如下所示:
我的问题是如何创建一个可以计算总时间的度量,给定报告中当前选择的日期过滤器,并且可以用来创建上图。
非常感谢任何帮助!
亲切的问候, 彼得
您可以使用 M (Power Query) 实现此目的,我的解决方案不会像 "IntervalType" 那样管理您要求的所有详细信息,但允许您在输入标准化后获取所需的行。
下面的 M 脚本将满足以下要求(您可以使用高级编辑器查看完整脚本):
- 所有行和使用的指标共享相同的度量单位,即:天
{here you have already loaded your table}
/*Calculate the difference between the 2 dates in days*/
/*note that if the end date is 9999-12-31 you may want to set an upper limit*/
#"Added Custom" = Table.AddColumn(#"Changed Type", "DaysInterval", each Duration.Days([EndDate]- [StartDate])),
/*Calculate how many times the service will be performed in the calculated interval*/
#"Added Custom1" = Table.AddColumn(#"Added Custom", "IntervalOccurence", each Number.RoundDown([DaysInterval]/[Interval])),
/*Use what has been calculated so far to create a list of dates for each row*/
#"Added Custom2" = Table.AddColumn(#"Added Custom1", "ListDates", each List.Dates([StartDate],[IntervalOccurence],#duration([Interval], 0, 0, 0))),
/*Expand the list to rows (using the UI click on the arrows in the column header)*/
#"Expanded ListDates" = Table.ExpandListColumn(#"Added Custom2", "ListDates")
之后,您只需删除不需要的列。