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

Get Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.

Reply
mleech
Frequent Visitor

Find first occurrence of a flag

Hi, 

I have a table which lists the customer number, ebill, trans date and trans time.  I am trying to determine the first time the ebill column is "Y".  I thought maybe I need to use a MIN calculation but am not sure how to do this.

 

Thanks

 

Capture.PNG

 

1 ACCEPTED SOLUTION

Hi,

 

Try this calculated column formula

 

=if('Ebill test'[EBILL]="Y",if(CALCULATE(MIN('Ebill test'[TRANS_DATE]),FILTER('Ebill test','Ebill test'[CUST_KEY]=EARLIER('Ebill test'[CUST_KEY])&&'Ebill test'[EBILL]="Y"))='Ebill test'[TRANS_DATE],"Y","N"),BLANK())

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

9 REPLIES 9
Chris_Botha
Helper I
Helper I

I would appreciate some help.

I am just starting to use Power Query in Excel.

I have a column with bank code.

OPEN BALANCE is a code that occures many times, but I need to remove rows of all occurences after the first one.

I was thinking the easiest would be to create a new custom column with will  be checking the CODE column and returning "First" when it finds the first OPEN BALANCE code and maybe "More" when it finds the rest of the OPEN BALANCE entries and then "Other" for all other codes.  Then I can easily just use filter to remove the "More" ones.

Kind regards

Hi,

Share some data and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ashish_Mathur
Super User
Super User

Hi,

 

Do you want to know that per Cust_key or across all Cust-keys?  Also, what result do you want - Date or Time?  Share your expected result.  Share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi, 

 

Yes sorry if my question was not detailed enough.  I am looking to flag or indicate the first date a custmer has a "Y" under Ebill field.  I would like to know that per unique Cust_key.

 

What I want to create is a field "First Ebill" and a Y if its the first occurence and a "N" if its not.  So in the example of CUST_KEY 0019068, I would like to have a "Y" in the "First Ebill" column in the row with the TRANS_DATE 9/28/2016 and "N" for all other rows for that CUST_KEY

Hi,

 

I am assuming you want this as a calculated column formula (and not a measure).  Am i correct?  If yes, then share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Yes I want a calculated column and not a measure.  I have attached a link to my file.

 

Thanks,

 

https://www.dropbox.com/s/zeo903xmir04yh2/test0319.pbix?dl=0

Hi,

 

Try this calculated column formula

 

=if('Ebill test'[EBILL]="Y",if(CALCULATE(MIN('Ebill test'[TRANS_DATE]),FILTER('Ebill test','Ebill test'[CUST_KEY]=EARLIER('Ebill test'[CUST_KEY])&&'Ebill test'[EBILL]="Y"))='Ebill test'[TRANS_DATE],"Y","N"),BLANK())

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

That worked!!! 

 

Thank you so much

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.