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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
M3nbk
Regular Visitor

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
Community Champion
Community Champion

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.