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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Countifs equivalent matching variable criteria

Hi, I've had a search and found some countifs solutions for powerBI but none that I can see that are a solution to my  goal so I'm hoping that somone could share a possible solution.

 

Summary: I need to flag rows true or false if they are new based on a variable criteria match from 2 columns.

The Excel formula I use is quite simple;

=COUNTIFS(A:A,"<"&A2,C:C,C2)=0

 

So if there is a row found where the Date in column A is less than the current row date and the HostOrderID is the same as the current row HostOrderID the record is not new as it appears in previous rows (count is > 0) and is flagged FALSE otherwise it's new (count = 0) and flagged TRUE.

 

I have tried this but it returns true for all rows.

alchem1st_0-1634523719721.png

Example data set;

 ABC
1DateNew PRHostOrderId
28/09/2021TRUEPldOrd/16877001//
39/09/2021FALSEPldOrd/16877001//
410/09/2021FALSEPldOrd/16877001//
511/09/2021FALSEPldOrd/16877001//
612/09/2021FALSEPldOrd/16877001//
713/09/2021FALSEPldOrd/16877001//
814/09/2021FALSEPldOrd/16877001//
98/09/2021TRUEPldOrd/21105414//
109/09/2021FALSEPldOrd/21105414//
1110/09/2021FALSEPldOrd/21105414//
1211/09/2021FALSEPldOrd/21105414//
1312/09/2021FALSEPldOrd/21105414//
1413/09/2021FALSEPldOrd/21105414//
1514/09/2021FALSEPldOrd/21105414//

 

Thanks in advance for any advice offered 🙂

 

Regards

Andrew

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , a new column like

if([Date] < minx(filter(Table,[HostOrderId]  =earlier([HostOrderId]) ),[Date]) , True(), false() )

 

or

 

if([Date]<= minx(filter(Table,[HostOrderId]  =earlier([HostOrderId]) ),[Date]) , True(), false() )

 

Change as per need

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Thanks @amitchandak & @TheoC  for your prompt responses. Your help is much appreciated !!

A pleasure @Anonymous! All the best 🙂

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

TheoC
Super User
Super User

Hi @Anonymous 


You can use something such as the following calculated column. 

col_Date = 

VAR _CurrentHost = 'Table'[HostOrderId]
VAR _Date = 'Table'[Date]
VAR _FirstDate = MIN ( 'Table'[Date] )
VAR _CountDate = COUNTROWS ( FILTER ( ALL ( 'Table' ) , _Date = 'Table'[Date] ) )
VAR _CountHost = COUNTROWS ( FILTER ( ALL ( 'Table' ) , _CurrentHost = 'Table'[HostOrderId] ) )

RETURN

IF ( _CountDate > 1 && _CountHost > 1 && _Date = _FirstDate , TRUE , FALSE )

 

TheoC_1-1634530225904.png

 

Hope it helps 🙂

 

Theo

PS - my bad, after I posted this I noticed @amitchandak had a response as well. I had it in draft for a bit. Apologies!  Please give the solution to @amitchandak if his gives you what you want.

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

amitchandak
Super User
Super User

@Anonymous , a new column like

if([Date] < minx(filter(Table,[HostOrderId]  =earlier([HostOrderId]) ),[Date]) , True(), false() )

 

or

 

if([Date]<= minx(filter(Table,[HostOrderId]  =earlier([HostOrderId]) ),[Date]) , True(), false() )

 

Change as per need

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
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!

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.

Top Solution Authors