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! Learn more

Reply
jts_
Helper I
Helper I

HELP! IF statement with GROUP BY logic

Hi,

 

As the attached picture shows, I have the data of a customer's historical visit date & the future appointment date.

As long as this customer has a future appointment booked (>= today), he/ she will be identified as an active customer, otherwise, this person will be marked as an inactive customer. Also, I would like to track the most recent appointment date of these active customers.

I have been trying to utilize min() & max() function to identify active/ inactive users. However, that is not practical since the appointment that occurred in the past will be identified as inactive, and it will create an ambiguity that a person will be categorized as both active and inactive at the same time.

 

I highly appreciate your thoughts/ comments in advance!

 

 

Question.PNG

1 ACCEPTED SOLUTION
mohammedadnant
Impactful Individual
Impactful Individual

Hi @jts_ 

 

Interesting requirement,

please create 2 measures

ActiveOrNot = 
VAR _MaxDate =
CALCULATE ( MAX ( VisitorTable[VisitDate] ), ALL ( VisitorTable[VisitDate] ) )
RETURN
IF ( _MaxDate < TODAY (), "No", "Yes" )
NextVisitDate = 
CALCULATE (
MIN ( VisitorTable[VisitDate] ),
ALL ( VisitorTable[VisitDate] ),
VisitorTable[VisitDate] > TODAY ()
)

 

If this solves your issue, please give thumbs up (kudos) and marked this answer as your solution.

 

Thanks & Regards,

Mohammed Adnan

Learn Power BI: https://www.youtube.com/c/taik18

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!

Thanks & Regards,
Mohammed Adnan
Learn Power BI: https://www.youtube.com/c/taik18

View solution in original post

2 REPLIES 2
mohammedadnant
Impactful Individual
Impactful Individual

Hi @jts_ 

 

Interesting requirement,

please create 2 measures

ActiveOrNot = 
VAR _MaxDate =
CALCULATE ( MAX ( VisitorTable[VisitDate] ), ALL ( VisitorTable[VisitDate] ) )
RETURN
IF ( _MaxDate < TODAY (), "No", "Yes" )
NextVisitDate = 
CALCULATE (
MIN ( VisitorTable[VisitDate] ),
ALL ( VisitorTable[VisitDate] ),
VisitorTable[VisitDate] > TODAY ()
)

 

If this solves your issue, please give thumbs up (kudos) and marked this answer as your solution.

 

Thanks & Regards,

Mohammed Adnan

Learn Power BI: https://www.youtube.com/c/taik18

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!

Thanks & Regards,
Mohammed Adnan
Learn Power BI: https://www.youtube.com/c/taik18

Thank you @mohammedadnant !

This is exactly what I was looking for, and it perfectly solve my issues!

Thanks a lot!!!

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