4 Replies Latest reply on Jun 26, 2018 6:28 AM by Patrick Weber

    issue: date calculation between different intervalls

    Patrick Weber

      Hi Tableau friends,

       

      I created a calculation (current_Intervall) which is able to show the start date of an intervall based on the current date (see my attached workbook).

      The current date can be set up by parameter Test_date.

       

      I think something is missing in my logic because e.g. Test_Date = June 26, 2018 then field "current_intervall" will show both start dates of June and July 2018.

      In this case the next month (start_date= June 19) is correct. How I have to modify the logic that May 18 won't be shown?

       

      current_Intervall:

       

      DATE(( 
      IF [Test Date]>=[Start_Date] and [Test Date]<=[End_Date]  Then str(date([Start_Date])) 
      ELSEIF [Year]=DATEPART('year',[Test Date]) and [Month]=DATEPART('month',[Test Date]) and [Test Date]>=[Start_Date] and [Test Date]>[End_Date] 
      Then STR( DATEADD('month',1,[Start_Date])) END  
      ))
      

       

      I think the issue appears if the current date is in the same month when another intervall already starts.

       

      Any hints or tips?

      Thanks in advance.