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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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