在 Power Bi 中计​​算 table 中的实例

Counting instances in a table in Power Bi

我正尝试在 Power Bi 中制作报告,但失败得很厉害。我有一个包含测试结果的数据库。数据库有三个 tables,tests,testresults 和 states。它们看起来像这样:

test_id name
1 test1
2 testb
status_id name
1 pass
2 fail
3 skip
result_id name_id status_id
1 1 1
2 1 2
3 2 1

我正在尝试在 Power Bi 中创建一个报告,其中包含一个 table,其中包含一个测试列表以及每个测试失败的次数。我曾尝试向测试 table 添加一个度量列,但我似乎总是以添加 status_id 的列结束。因此,如果测试通过一次并失败两次,则计数为 5。我将如何编写一个查看结果 table 并计算每次测试失败次数的度量?

我希望得到像这样的东西:

test failed count
test1 2
testb 1
testc 6

我想你只需要一个像这样的简单过滤条件:

failed count = CALCULATE ( COUNTROWS ( Results ), Statuses[name] = "fail" )