如何使用电源查询计算组合结果并放在单独的表中

发布于 2025-02-08 20:17:39 字数 2652 浏览 2 评论 0原文

我的表包含以下信息:

主机名测试名称结果
host_01test-01Pass
host_01test-02fail>失败
host_01test-03n/a
HOST_01TEST-04PASS
HOST_01TEST-05PASS
host_02test-01Pass
host_02test-02 test-02fail> faff
host_02Test-03Fail
Host_02Test-04Pass

Now I want/need to transform this to the following result:

Host nameNum_of_Tests_per_HostNum_PassedNum_FailedNum_N/A
Host_015311
Host_02422null

我创建了查询以提取Disctinct主机列表并计算出不同的“测试名称 - 结果”的情况。但是我无法围绕如何合并这些查询来创建结果表。

这可能是“ Arggh ...我为什么没有想到!”解决方案,但似乎无法抓住它。

非常感谢。

I have table containing the following information:

Host nameTest nameResult
Host_01Test-01Pass
Host_01Test-02Fail
Host_01Test-03N/A
Host_01Test-04Pass
Host_01Test-05Pass
Host_02Test-01Pass
Host_02Test-02Fail
Host_02Test-03Fail
Host_02Test-04Pass

Now I want/need to transform this to the following result:

Host nameNum_of_Tests_per_HostNum_PassedNum_FailedNum_N/A
Host_015311
Host_02422null

I created the queries to extract the disctinct host list and count the distinct "Test name - Result" occurances. But I can't get my head around how to merge these queries to create the results table.

This will probably be an "Arggh ... Why didn't I think of that!!!" solution, but can't seem to catch it.

Many thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一人独醉 2025-02-15 20:17:39

假设单元格内容为nulls而不是文字说null,

let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Grouped Rows" = Table.Group(Source, {"Host name"},{
    {"Num_of_Tests_per_Host", each List.Count(List.Distinct([Test name])), type number},
    {"Num_Passed", each List.NonNullCount([Passed]), type number},
    {"Num_Failed", each List.NonNullCount([Failed]), type number},
    {"Num_N/A", each List.NonNullCount([#"N/A"]), type number}
})
in #"Grouped Rows"

Assuming the cell contents are nulls instead of text saying null,

let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Grouped Rows" = Table.Group(Source, {"Host name"},{
    {"Num_of_Tests_per_Host", each List.Count(List.Distinct([Test name])), type number},
    {"Num_Passed", each List.NonNullCount([Passed]), type number},
    {"Num_Failed", each List.NonNullCount([Failed]), type number},
    {"Num_N/A", each List.NonNullCount([#"N/A"]), type number}
})
in #"Grouped Rows"
秉烛思 2025-02-15 20:17:39

尝试一下:

let

//Change table name in next line to reflect actual data source
    Source = Excel.CurrentWorkbook(){[Name="Table18"]}[Content],

//set data types
    #"Changed Type" = Table.TransformColumnTypes(Source,{
        {"Host name", type text}, 
        {"Test name", type text}, 
        {"Result", type text}}),

//Group by Host Name
//  Aggregate to get total of tests, Pass, Fail, N/A
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Host name"}, {
       {"Num_of_Tests_per_Host", each Table.RowCount(_), Int64.Type},
       {"Num_Passed", (t)=>List.Count(List.Select(t[Result], each _="Pass")), Int64.Type},
       {"Num_Failed", (t)=>List.Count(List.Select(t[Result], each _="Fail")), Int64.Type},
       {"Num_N/A", (t)=>List.Count(List.Select(t[Result], each _="N/A")), Int64.Type}
        })
in
    #"Grouped Rows"

Try this:

let

//Change table name in next line to reflect actual data source
    Source = Excel.CurrentWorkbook(){[Name="Table18"]}[Content],

//set data types
    #"Changed Type" = Table.TransformColumnTypes(Source,{
        {"Host name", type text}, 
        {"Test name", type text}, 
        {"Result", type text}}),

//Group by Host Name
//  Aggregate to get total of tests, Pass, Fail, N/A
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Host name"}, {
       {"Num_of_Tests_per_Host", each Table.RowCount(_), Int64.Type},
       {"Num_Passed", (t)=>List.Count(List.Select(t[Result], each _="Pass")), Int64.Type},
       {"Num_Failed", (t)=>List.Count(List.Select(t[Result], each _="Fail")), Int64.Type},
       {"Num_N/A", (t)=>List.Count(List.Select(t[Result], each _="N/A")), Int64.Type}
        })
in
    #"Grouped Rows"

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文