0

我从发生在位置的故障列表开始

failureName, failureLocation
failure a, location 1
failure b, location 1
failure a, location 2
failure a, location 1
<etc>

summarize count()我可以通过使用按位置将其转换为此表

failureName, failureLocation, count
failure a, location 1, 100
failure a, location 2, 50
failure b, location 1, 10
<etc>

我想将计数转换为百分比。失败的基础,所以我需要为每个失败名称添加一个总和。我的目标是最终得到这张表:

failureName, failureLocation, count, sumPerFailureName
failure a, location 1, 100, 150
failure a, location 2, 50, 150
failure b, location 1, 10, 10
<etc>

建议?

4

1 回答 1

2

试试这个,把你从第二个表带到第三个(并扩展百分比的计算列):

let T = datatable(failureName:string, failureLocation:string, ['count']:long) [ 'failure a', 'location 1', 100, 'failure a', 'location 2', 50, 'failure b', 'location 1', 10, ] ; T | summarize sumPerFailureName = sum(['count']) by failureName | join ( T ) on failureName | project failureName, failureLocation, ['count'], sumPerFailureName, percentage = round(100.0 * ['count'] / sumPerFailureName, 2)

于 2018-11-05T23:09:35.347 回答