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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Filter Previous Data DAX on condition

Imagine I have the following dataset.

Product / IsOpen / Date
1           / 0          / 21 / 05 / 2009

1         / 1           / 22 / 05 / 2009

How can I filter/delete data previously to the first IsOpen = 1 ?? By creating a new table or even in Powerquery. I just want data starting from its first IsOpen = 1 per Product.

Thanks!

1 ACCEPTED SOLUTION

I've done this with 2 calcualted columns...  (You could combine them in 1 if you wanted).

 

VisCheck looks for First Date IsOpen = 1 comparing each Produt Line to the EARLIER Product line.  This allows for different dates depending on Product.  Then Yes-No compares the dates placing 0 or 1.  I then Filter by only 1.


** I noticed you said "Product A Completely Gone", but there was 1 IsOpen with a date?  Mabye you can play with the > or >= sign in the VisCheck to acomplish what you need.

 

VisCheck = CALCULATE(FIRSTDATE(Prod[Date]), Prod[IsOpen] = "1" ,FILTER( Prod, Prod[Product] = EARLIER(Prod[Product])))

Yes-NO = IF(Prod[Date] < Prod[VisCheck],0,1)

 

Thank You,

FOrrest

 

Capture.PNG




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




View solution in original post

4 REPLIES 4
fhill
Resident Rockstar
Resident Rockstar

... is that first IsOpen for ALL products, or by Product?  What about Products that close after opening?  What is your desired output based on these values?

 

ProductIsOpenDate
A01/2/2012 0:00
A01/5/2012 0:00
A11/7/2012 0:00
B13/1/2012 0:00
B13/5/2012 0:00
B13/7/2012 0:00
C06/2/2012 0:00
C16/4/2012 0:00
C16/6/2012 0:00
D012/20/2011 0:00
D112/23/2011 0:00
D012/31/2012 0:00



Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




Anonymous
Not applicable

by product.
So in your dataset, this would happen:

Product A completely gone
Product B every row
PRoduct C the last two.. since the first one is IsOpen = 0 D the last two as well..

Products that close after opening would appear.. as long as opening is first, then everything appears.. everything that appears as closed before the first isOpen = 1 should be gone.
I think I might found the solution, will let you know if it works

I've done this with 2 calcualted columns...  (You could combine them in 1 if you wanted).

 

VisCheck looks for First Date IsOpen = 1 comparing each Produt Line to the EARLIER Product line.  This allows for different dates depending on Product.  Then Yes-No compares the dates placing 0 or 1.  I then Filter by only 1.


** I noticed you said "Product A Completely Gone", but there was 1 IsOpen with a date?  Mabye you can play with the > or >= sign in the VisCheck to acomplish what you need.

 

VisCheck = CALCULATE(FIRSTDATE(Prod[Date]), Prod[IsOpen] = "1" ,FILTER( Prod, Prod[Product] = EARLIER(Prod[Product])))

Yes-NO = IF(Prod[Date] < Prod[VisCheck],0,1)

 

Thank You,

FOrrest

 

Capture.PNG




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




Anonymous
Not applicable

This is a good solution, in my case the time is also important.
Anyway, decided to do via power query and it works. 
Thanks!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors