Forum Discussion

AndreDeLuca's avatar
AndreDeLuca
Frequent Visitor
2 years ago
Solved

How to calculate a column with the difference between failed logs

Hello everyone, Thanks in advance for anyone that helps, We have a table that shows us the log of a process, and if it was successful or not: The idea here is to calculate the record of days...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi AndreDeLuca ,

    Based on my testing, please try the following methods:

    1.Create the simple table.

    2.Create the new column to calculate the last failure for each row.

    Date of Last Failure = 
    VAR date_ = 'Log table'[Date]
    RETURN
    CALCULATE(
        MAX('Log table'[Date]),
        FILTER(
            ALL('Log table'),
            'Log table'[Date] < date_ && 'Log table'[Log status] = "failed"
        )
    )

    3.Create the new column to calculate the days since the last failed.

    Days Since Last Failure = 
    DATEDIFF(
        [Date of Last Failure],
        'Log table'[Date],
        DAY
    )

    4.Create the new measure to calculate the max days of the column.

    Max Days Without Failure = MAXX(ALL('Log table'), [Days Since Last Failure])

    5.The result is shown below.

    Best Regards,

    Wisdom Wu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.