2 Replies Latest reply on Oct 28, 2013 9:49 AM by Ramon Martinez

    How to create calculated field based on data in different rows

    Alissa Anderson

      I'm relatively new to Tableau and most of the analyses I want to do involve creating calculated fields that add/subtract data displayed in different rows. So for example how do I create a calculated field that is equal to the employment rate for California minus the employment rate for the US for each date (X/X/XX). Here's what my data looks like:

       

      Date     Place     Employment Rate

      1/1/11     CA     .54

      1/1/11     US      .59

      2/1/11     CA     .55

      2/1/11     US     .59

       

      Essentially I want to subtract the employment rate in one row (CA) from that of another row (US) whenever the dates in the rows are the same. I'd like the data to look like this:

       

      Date     Place     Employment Rate     Diff Emp Rate

      1/1/11     CA     .54                              .05

      1/1/11     US      .59                             .05

      2/1/11     CA     .55                              .04

      2/1/11     US     .59                              .04

       

      Thanks!