Kusto 查询以按总数的百分比显示摘要

Kusto query to show summary by percent of totals

我正在尝试获取失败总数百分比的摘要,请参阅下面的查询。这很好,但我希望它显示 Vendor1=0.5 和 Vendor2=0.5(50% 失败),而不仅仅是 Vendor1=1 (一次失败为 0),Vendor2=2(两次失败为 0)

datatable (Vendor:string, failure:int)
    ["Vendor1",3,
    "Vendor2",0,
    "Vendor2",0,
    "Vendor2", 7,
    "Vendor1",0,
    "Vendor2", 1]
| where failure == 0    
| summarize Failures=count() by Vendor

请检查下一个查询是否解决了您的情况:

datatable (Vendor:string, failure:int)
    ["Vendor1",3,
    "Vendor2",0,
    "Vendor2",0,
    "Vendor2", 7,
    "Vendor1",0,
    "Vendor2", 1]   
| summarize Failures=countif(failure == 0), Total=count() by Vendor
| extend Result=Failures*1.0/Total

的细微变化:

datatable (Vendor:string, failure:int)
    ["Vendor1",3,
    "Vendor2",0,
    "Vendor2",0,
    "Vendor2", 7,
    "Vendor1",0,
    "Vendor2", 1]   
| summarize Result = 1.0*countif(failure==0)/count() by Vendor

Demo