Search code examples
countpowerbidax

How to count the row count matching the selected data set, where the issue type match


I have built a star schema as below. I have two flat files loaded as test_execution_summary and defect_report. Records in the test execution summary is filtered using the practice name and then again the project name. After that I am using a visual filter to filter in cycles related to the recent release, which I calculate through a measure.

enter image description here

Relationships between tables are as follows:

  • defect_report[IssueKey] = test_execution_summary[ExecutionDefect]

  • test_cycle_details[cycleID] = test_Execution_summary[CycleID]]

In the defect table there are two types of issues, bugs and defects. I need to calculate the bug count of each cycle, selected for the latest release. I tried to use below measure, but it is making the bug count value empty.

Bugs Count 1 = CALCULATE(COUNTROWS(FILTER(defect_report, defect_report[Issue Type]="Bug")), RELATEDTABLE(test_execution_summary))

I have been trying different ways to get this to work, but i can't figure out the way. I am totally new to Power BI. Appreciate if someone can help me to figure out what i am doing wrong and how to fix this.

enter image description here


Solution

  • Try counting from the Fact table with the filter applied on the Dimension table:

    Bug Count 2 = 
      CALCULATE(
        DISTINCTCOUNTNOBLANK('test_execution_summary'[ExecutionDefect]),
        'defect_report'[Issue Type] = "Bug"
      )