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

Preparing for a certification exam? Ask exam experts all your questions on May 15th. Register 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
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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