Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Checking status for three most recent dates per device

Hi all,

 

I am trying to create an indicator that will tell me if there's an issue with a device. "Issue" is defined as the status = failed for all three of the most recent entries per device.

 

My data looks something like this:

DeviceDateStatus
A8/1/2020Pass
A8/4/2020Fail
A8/6/2020Pass
A8/7/2020Fail
B8/10/2020Pass
B8/11/2020Fail
B8/14/2020Fail
C4/1/2020Pass
C5/1/2020Fail
C6/1/2020Fail
C7/1/2020Fail
D8/3/2020Fail
D8/7/2020Fail
D8/15/2020Fail

 

And I need an indicator per device (column or measure, either way) that will display the following:

DeviceIssue?
AFALSE
BFALSE
CTRUE
DTRUE

 

I need to look at each device, find the three most recent dates for that device, check the statuses on those dates, and if all three statuses are fail, indicate that there's an issue. The three most recent dates may be different for different devices.

 

Any ideas? I'm completely stumped right now and would appreciate any help!

  • Anonymous  - I think you could do it by creating a custom column like:

     

    Rank = RANKX(FILTER('Table (2)', [Device] = EARLIER([Device])),[Date])

     

    Then you could create a measure like:

    Measure = 
        VAR __Table = SUMMARIZE(FILTER('Table (2)',[Rank]<=3),[Status])
    RETURN
        IF(MINX(__Table,[Status])="Fail" && COUNTROWS(__Table)=1,"TRUE","FALSE")

3 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Anonymous  - I think you could do it by creating a custom column like:

     

    Rank = RANKX(FILTER('Table (2)', [Device] = EARLIER([Device])),[Date])

     

    Then you could create a measure like:

    Measure = 
        VAR __Table = SUMMARIZE(FILTER('Table (2)',[Rank]<=3),[Status])
    RETURN
        IF(MINX(__Table,[Status])="Fail" && COUNTROWS(__Table)=1,"TRUE","FALSE")
    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you, Greg_Deckler! I knew there had to be a way to do this, I just couldn't figure it out.

       

      P.S. I've been benefitting from the solutions you've provided here for the past few years, so thanks for all your indirect help too 🙂

  • Hi,

    Here's a solution using measures only.  You may download my PBI file from here.

    Hope this helps.