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

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

Reply
patri0t82
Post Patron
Post Patron

Count of Rows based on MAX of Date Column and Other Filters

Hello,

I'm looking for someone to please correct my DAX formula below. It does not work. I think it reads fairly straightforward, however I'm obviously missing something.

I'm aware Power Query could handle this much easier, but I'm using DirectQuery and need to build it in a measure.

 

Any help is greatly appreciated.

 

 

Overdue Inspection Recommendations = 
CALCULATE (
        COUNT ( 'Inspection Recommendations'[Recommendation_ID] ),
        MAX ( [Target_Completion_Date] ), 
    
        'Inspection Recommendations'[Target_Completion_Date] < NOW ()
            && 'Inspection Recommendations'[Status] <> "CANCELLED"
            && 'Inspection Recommendations'[Status] <> "IMPLEMENTED"
            && 'Inspection Recommendations'[Status] = "APPROVED"
            && ( 'Inspection Recommendations'[Risk_Rank] = "Red"
            || 'Inspection Recommendations'[Risk_Rank] = "Orange"
            || 'Inspection Recommendations'[Risk_Rank] = "Yellow" )
    ) + 0

  

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @patri0t82 ,

 

The second parameter of CALCULATE is a filter, which can be a Boolean (true/false) expression or a table expression defining the filter.

 

Please try like:

Overdue Inspection Recommendations =
CALCULATE (
    COUNT ( 'Inspection Recommendations'[Recommendation_ID] ),
    TableName[ColumnName] = MAX ( [Target_Completion_Date] ),
    'Inspection Recommendations'[Target_Completion_Date] < NOW ()
        && 'Inspection Recommendations'[Status] <> "CANCELLED"
        && 'Inspection Recommendations'[Status] <> "IMPLEMENTED"
        && 'Inspection Recommendations'[Status] = "APPROVED"
        && ( 'Inspection Recommendations'[Risk_Rank] = "Red"
        || 'Inspection Recommendations'[Risk_Rank] = "Orange"
        || 'Inspection Recommendations'[Risk_Rank] = "Yellow" )
) + 0

CALCULATE - DAX Guide

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @patri0t82 ,

 

The second parameter of CALCULATE is a filter, which can be a Boolean (true/false) expression or a table expression defining the filter.

 

Please try like:

Overdue Inspection Recommendations =
CALCULATE (
    COUNT ( 'Inspection Recommendations'[Recommendation_ID] ),
    TableName[ColumnName] = MAX ( [Target_Completion_Date] ),
    'Inspection Recommendations'[Target_Completion_Date] < NOW ()
        && 'Inspection Recommendations'[Status] <> "CANCELLED"
        && 'Inspection Recommendations'[Status] <> "IMPLEMENTED"
        && 'Inspection Recommendations'[Status] = "APPROVED"
        && ( 'Inspection Recommendations'[Risk_Rank] = "Red"
        || 'Inspection Recommendations'[Risk_Rank] = "Orange"
        || 'Inspection Recommendations'[Risk_Rank] = "Yellow" )
) + 0

CALCULATE - DAX Guide

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

That makes perfect sense. Thanks for clearing it up for me!

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors