6 Replies Latest reply on May 13, 2016 1:07 PM by pooja.gandhi

    Grabbing Last Date if Value of Current Date is Null

    Jonathan Landesman

      Hello,

       

      I am new to Tableau and am having difficulty with what I imagine is an easy question.

       

      I have a series of economic data on countries, and various countries release their data at different times.  I would like to make a chart that automatically grabs the value of the series (call it GDP) on the most recent release, and lists the "as of" date next to it.

       

      The data look like this:

       

      CountryDateGDP
      USQ3 20152%
      USQ4 20151%
      USQ1 2016null
      JapanQ3 20150.3%
      JapanQ4 2015-1.2%
      JapanQ1 20160.7%

       

      And the output would be a barchart that says:

       

      US: Q4 2015: 1%

      Japan: Q1 2016: 0.7%.

       

      If I were writing it in R, the code would be:

       

      group_by(Country) %>%

           select (Country, Date, GDP) %>%

            filter(ifelse(max(Date) == null), lag(Date,1), Date)

       

      Thank you!

       

      J