Calculated field in tableau to find if the first row is Success or Failure

Div

I have the below data (from a table) with fields TransactionDate, UserID, and the StatusDesc. The goal is I want to show the userID, where the UserID does not have a login failure (indicated by statusDesc Column - 'Rejected') occurring prior on the same day as a successful login ( Sucessfull Login is indicated by statusDesc Column - 'Success').

Actual DATA

            TransactionDate                 UserId                      StatusDesc

            2018-12-02 00:00:01.957     [email protected]     Rejected
            2018-12-02 00:00:14.907     [email protected]     Success
            2018-13-02 00:00:22.390     [email protected]     Success
            2018-13-02 00:00:28.610     [email protected]     Rejected
            2018-14-02 00:00:22.390     [email protected]              Success
            2018-14-02 00:00:28.610     [email protected]              Rejected

Expected Result

            TransactionDate                 UserId                      StatusDesc
            2018-13-02 00:00:22.390     [email protected]     Success
            2018-14-02 00:00:22.390     [email protected]              Success 
Luke B

You can use an LOD (Level of Detail) expression in a Calculated Field for this. LOD's can be tricky to wrap your head around at first, but once you've used them a few times they become very handy.

  1. Create a new calculated field under Dimensions called "First Rejection of Day". This will have the timestamp of the first rejection of the day for the user, or null if there have been no rejections. Use the following code:

{ FIXED [UserId], DATE([TransactionDate]) : MIN(
    IF [StatusDesc] = "Rejected" THEN
      [TransactionDate]
    END
  )
}

  1. Create another calculated field called "Has Prior Rejection". Use the following code:

ISNULL([First Rejection of Day]) = FALSE AND [First Rejection of Day] <= [TransactionDate]

  1. Drag Has Prior Rejection to Filters, and select "False". This will filter out all records that have a prior rejection.

Screenshot in Tableau

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Tableau Calculated Field error

Tableau calculated field dates

Tableau calculated field

Mongoose: find by calculated field

mongodb find with calculated field

Error in Tableau calculated field formula

Second Max in Tableau Calculated Field

Tableau/SQL Calculated Field With Grouping

Tableau multiple charts with calculated field

Tableau Calculated Field using FIXED

Using filtered results as field for calculated field in Tableau

How to pass each row as an argument to R script from Tableau calculated field

Find smallest number in calculated field

Tableau calculated field summing up the values

Implementing a calculated field within my Tableau Viz

calculated field in tableau dependent on values in column

Tableau Calculated Field COUNTD Single Value

IF part in tableau calculated field is not getting executed

Tableau Calculated Field - across multiple measures

Create a calculated field to count dimension on a condition in Tableau

Vectorized lookup another row + calculated field

Tableau: Create a newline between text using a calculated field

Get Total Value of Bill Number - Tableau calculated field

Is it possible to count the number of occurrences of a calculated field's result in Tableau?

Regular Expresion in Tableau returns only Null's in Calculated Field

Calculated Field based on an Relation Aggregate with Filter Conditions in Tableau

Tableau calculated field distinct sum of metric base on selected dimensions

Pivot Table Column with Value and Calculated Field row per group?

Add calculated field based on past values of the row SQL