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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

How to countif with multiple conditions across table

Hi,

 

Please help me find out the following

 

Here is my current DAX
EX1 = COUNTROWS(FILTER(Terminate,CONTAINS('Hire 2022','Hire 2022'[ID],Terminate[ID])))

 

But another condition that need to be filtered is count if the effective date of Terminate is after the effective date of Hire 2022

 

Please let me know if it needs data support.

 

Thank you!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Please try:

Measure = 
COUNTROWS(
    FILTER(
        Terminate,
        CONTAINS('Hire 2022', 'Hire 2022'[ID], Terminate[ID]) &&
        CALCULATE(
            MIN('Hire 2022'[Effective Date]),
            'Hire 2022'[ID] = EARLIER(Terminate[ID])
        ) < Terminate[Effective Date]
    )
)

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 in the Power BI Forum

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

To elaborate, in case it helps.

Here is what the data look like

JULY1_1-1687419304738.png

The result from my DAX  - COUNTROWS(FILTER(Terminate,CONTAINS('Hire 2022','Hire 2022'[ID],Terminate[ID])))

is 5

But I would like to add another filter, which will count when the effective date of Hire 2022 is before the effective date of Termination.

And the expected result is 3

 

Thank you in advance 

Anonymous
Not applicable

Hi @Anonymous ,

 

Please try:

Measure = 
COUNTROWS(
    FILTER(
        Terminate,
        CONTAINS('Hire 2022', 'Hire 2022'[ID], Terminate[ID]) &&
        CALCULATE(
            MIN('Hire 2022'[Effective Date]),
            'Hire 2022'[ID] = EARLIER(Terminate[ID])
        ) < Terminate[Effective Date]
    )
)

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 in the Power BI Forum

Anonymous
Not applicable

It works.

Thank you! 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.