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
VP1310
Frequent Visitor

Flag rows based on conditions

Hi Everyone,

I have a set of data as shown below,

CustomerInvoicedateEvent
A1/8/2023Trial
A4/8/2023Purchase
B1/8/2023Purchase
B3/8/2023Exchange
B4/8/2023Demo
C1/8/2023Purchase
C2/8/2023Exchange
C3/8/2023Trial
D1/8/2023Trial
D2/8/2023Purchase
D3/8/2023Exchange
D4/8/2023Purchase
E1/8/2023Demo
E4/8/2023Purchase

 

I need to create a new column say "IncludeFlag". This column should contain a flag based on the criterias as given below.

1) If the Customer's first Event is Trial or Demo then "1" should be flagged to every row of the customer.

2) "0" to be flagged incase the Event is not Trial or Demo or if the first event is not Trial or Demo.

Below is the desired output.

 

CustomerInvoicedateEventIncludeFlag
A1/8/2023Trial1
A4/8/2023Purchase1
B1/8/2023Purchase0
B3/8/2023Exchange0
B4/8/2023Demo0
C1/8/2023Purchase0
C2/8/2023Exchange0
C3/8/2023Trial0
D1/8/2023Trial1
D2/8/2023Purchase1
D3/8/2023Exchange1
D4/8/2023Purchase1
E1/8/2023Demo1
E4/8/2023Purchase1

 

Please suggest a way in which, I can achieve this.

 

Thank you and Regards

 

 

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

pls try this

 

 

Flag = 
VAR _t1 = [Customer]
VAR _MinDate = MINX(FILTER(ALL('Table'),'Table'[Customer]=_t1),[Invoicedate])
VAR _tbl = FILTER(ALL('Table'),'Table'[Customer]=_t1&&'Table'[Event]="Trial"&&[Invoicedate]=_MinDate)
RETURN
COUNTROWS(_tbl)

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

 

Screenshot_2.png

View solution in original post

4 REPLIES 4
YASHASHRI
Helper I
Helper I

can you please tell me what is

VAR _t1 = [Customer]

Screenshot_2.png

Ahmedx
Super User
Super User

pls try this

 

 

Flag = 
VAR _t1 = [Customer]
VAR _MinDate = MINX(FILTER(ALL('Table'),'Table'[Customer]=_t1),[Invoicedate])
VAR _tbl = FILTER(ALL('Table'),'Table'[Customer]=_t1&&'Table'[Event]="Trial"&&[Invoicedate]=_MinDate)
RETURN
COUNTROWS(_tbl)

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

 

Screenshot_2.png

VP1310
Frequent Visitor

Thanks a lot, works as per my requirement.

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