Mateo
Mateo

Reputation: 1971

Counting instances in a table in Power Bi

I am trying to make a report in Power Bi and failing badly. I have a db containing test results. The db has three tables, tests, testresults and statuses. They look something like this:

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

I am trying to create a report in Power Bi that will have a table that contains a list of tests and how many times each test failed. I have tried adding a measure column to the tests table but I always seem to end up with a column that adds up the status_id. So if a test passes once and fails twice, ill get a count of 5. How would I write a measure that looks through the results table and counts the number of time each test fails?

I hoping to get something that looks like:

test failed count
test1 2
testb 1
testc 6

Upvotes: 0

Views: 169

Answers (1)

Alexis Olson
Alexis Olson

Reputation: 40204

I think you just need a simple filter condition like this:

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

Upvotes: 1

Related Questions