Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
M3nbk
New Member

DAX Calculate sum of rows within two tables with relationship by ID

 

Tables:

1. Incidents table → list of incidents, with fields including Metric ID and State(Closed, In progress, etc).

2. Metrics table → primary key Metric ID, field Value (monthly max allowed).

 

I want → in the Metrics table, create a calculated column that shows the count of incidents with Status = "Closed" for each Metric ID based on the dates defined in the slicer. (01/01/2025 - 07/31/2025)

 

Expected result:

In table metrics, there is a unique row with the value of the monthly max allowed ticket.

In table Incidents, there are 5 Incidents resolved, which fall under the parameters

the total debug I want to consolidate the sum of the incidents. The count should be 5, as it is the sum of the debug count(Incidents table), but the result of the formula is 9. It is not taking into consideration the visual filter and it is showing all the data available in the incident table.

M3nbk_0-1756132120111.png

VAR TotalDebugCount =
    CALCULATE(
        COUNTROWS(Incidents),
        KEEPFILTERS(Incidents[State] = "Closed"),
        KEEPFILTERS(Incidents[Opened])  
    )
RETURN
TotalDebugCount

 

The value remains unchanged when I modify the range of the slicer/visual. How can I fix this?
 
Thanks
1 ACCEPTED SOLUTION
FBergamaschi
Solution Sage
Solution Sage

Hi @M3nbk 

calculated columns are static calculations that never change.

You need a measure in this case, here is the code

 

CALCULATE(
        COUNTROWS(Incidents),
        Incidents[State] = "Closed"
    )

 

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

View solution in original post

2 REPLIES 2
Shahid12523
Power Participant
Power Participant

Use a measure, not a calculated column, to make slicers work.


ClosedIncidentCount :=
CALCULATE(
COUNTROWS(Incidents),
Incidents[State] = "Closed"
)


This will respect slicers like date range and Metric ID.
If you want to sum debug counts instead of just counting rows:


TotalDebugCount :=
CALCULATE(
SUM(Incidents[DebugCount]),
Incidents[State] = "Closed"
)

Shahed Shaikh
FBergamaschi
Solution Sage
Solution Sage

Hi @M3nbk 

calculated columns are static calculations that never change.

You need a measure in this case, here is the code

 

CALCULATE(
        COUNTROWS(Incidents),
        Incidents[State] = "Closed"
    )

 

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.