cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

Find first occurence of value according to date and string

Hello datanauts,

 

In PBI (example in the table below), I need to get the column "VeryFirstTestOkay", which gives out boolean values according to multiple filtering conditions.

 

The column "VeryFirstTestOkay" shall only return 1 if:

  1. all rows have been ordered by "Timestamp" ascending &&
  2. "Text" contains "0 Errors" &&
  3. "Text" hasn't been "0 Errors" || ">0 Errors" before

In humane words: I have to find out, if an article has gone through a test without errors at the first time or not.

 

ArticleTimestampTextVeryFirstTestOkayWhy "FirstTestOkay" has it's value
A04.08.2020 10:27System Start00 - because "Text" doesn't contain ">0 Errors"
A04.08.2020 10:29Resistance Test00 - because "Text" doesn't contain ">0 Errors"
A04.08.2020 10:300 Errors11 - because "Text" does contain ">0 Errors"
B04.08.2020 10:35System Start00 - because "Text" doesn't contain ">0 Errors"
B04.08.2020 10:36Failure00 - because "Text" doesn't contain ">0 Errors"
C04.08.2020 10:40System Start00 - because "Text" doesn't contain ">0 Errors"
C04.08.2020 10:41Resistance Test00 - because "Text" doesn't contain ">0 Errors"
C04.08.2020 10:431 Error00 - because "Text" does contain ">0 Errors"
C04.08.2020 10:44System Start00 - because "Text" doesn't contain ">0 Errors"
C04.08.2020 10:460 Errors11 - because "Text" does contain ">0 Errors" and article hasn't been tested before.
A05.08.2020 15:11System Start00 - because "Text" doesn't contain ">0 Errors"
A05.08.2020 15:121 Error00 - because "Text" doesn't contain ">0 Errors" & "VeryFirstTestOkay" has already been set to 1 for this article
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User IX
Super User IX

Re: Find first occurence of value according to date and string

@dyiezb24 - So basically this is Lookup Min/Max https://community.powerbi.com/t5/Quick-Measures-Gallery/Lookup-Min-Max/m-p/985814#M434

 

VeryFirstTestOkay = 
  VAR __Min = MINX(FILTER('Table',[Text] = "0 Errors" && [Article] = EARLIER('Table'[Article])),[Timestamp]
RETURN
  IF([Timestamp] = __Min && [Text] = "0 Errors",1,0)

 


---------------------------------------

Not link spamming! If I posted a link in reply it is because I did assume you know how to search the web but thought it was the fastest way to fix your issue.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




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

Proud to be a Super User!




View solution in original post

1 REPLY 1
Highlighted
Super User IX
Super User IX

Re: Find first occurence of value according to date and string

@dyiezb24 - So basically this is Lookup Min/Max https://community.powerbi.com/t5/Quick-Measures-Gallery/Lookup-Min-Max/m-p/985814#M434

 

VeryFirstTestOkay = 
  VAR __Min = MINX(FILTER('Table',[Text] = "0 Errors" && [Article] = EARLIER('Table'[Article])),[Timestamp]
RETURN
  IF([Timestamp] = __Min && [Text] = "0 Errors",1,0)

 


---------------------------------------

Not link spamming! If I posted a link in reply it is because I did assume you know how to search the web but thought it was the fastest way to fix your issue.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




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

Proud to be a Super User!




View solution in original post

Helpful resources

Announcements

August Community Highlights

Check out a full recap of the month!

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power BI

Join us for an in-depth look at the new Power BI features and capabilities at the free Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors