3 Replies Latest reply on Aug 15, 2017 11:49 AM by Joe Oppelt

    Date range slider values for calculation

    Ankalka jethi



      Is there a way I can use the values in the date range slider (filter ) in calculated fields.


      I have a date field Forecast period end date , which I am using as a filter (date range slider), I am trying to figure out the difference in years in the start date and the end date. And then use it in another calculated field.


      Thanks in advance.


      Kind Regards,


        • 1. Re: Date range slider values for calculation
          Jim Dehner

          Here is one way - see the attached superstore example

          Order date is a filter with a slider - then use window_max to find the last order date in the viz


          the formula just looks at the sales for the last 5 days only and set the rest to 0

          if DATEDIFF('day',attr([Order Date]),WINDOW_MAX(attr([Order Date])))

          <=5 then sum([Sales]) else 0 end



          Let me know if this solved your issues



          If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.

          • 2. Re: Date range slider values for calculation
            Joe Oppelt

            I'm not aware of a way to pull the exact end-of-range dates from the filter itself.  Tableau doesn't give us those values stored anywhere that I know of.


            But you can sort of derive them by calc-ing the MAX value on the sheet and the MIN value on the sheet.  However that only gives you the max and min of the rows that fit the range, not the actual range value itself.  For example, if you never have data on a Sunday, but if the user selects a date that falls on a sunday, the MAX value you will have on the sheet will be Saturday (or even Friday, if you have no Saturday data.) 

            • 3. Re: Date range slider values for calculation
              Joe Oppelt

              And, in fact, that's what Jim demonstrates in his example.