4 Replies Latest reply on Jul 16, 2018 6:04 AM by Daniel Segura

    Leave out Current Week with Calculated Field

    Daniel Segura

      Hello,

       

      I need to leave out the current week. I have found a way of doing it with this calculated field:

       

      [Current Week Filter]

      DATEDIFF('week',DATETRUNC('week',[Reporting Day],'Sunday'),DATETRUNC('week',TODAY(),'Sunday')) >= 1

       

      I also created a filter:

       

      [Exclude Current Filter]

      if [Current Week Filter] then

           'Yes'

      else

           'No'

      end

       

      It works! However, if I want to include the current week along with the other ones, I have to either: remove the filter or short-circuit it by selecting True AND False.

       

      In other words, I'd like an 'Exclude Filter' that when 'Yes' is selected it leaves out the current week and when 'No' is checked, everything is shown.

       

      I'm sure that it's a silly thing... Maybe it's the calculated field or the Yes/No switch...

       

      Any Help?

        • 1. Re: Leave out Current Week with Calculated Field
          Naveen B

          Hi Daniel,

           

          I have created sample data based on your requirement like below with some weeks (week 22 - week 29)

           

           

          Step 1: Create a Parameter named Include Current Week? and Provide the values string Yes or No

           

           

          Step 2: Create a calculated field "Include Current Week Calc" to tag the parameter to date field

           

           

          Step 3: Drag the Calculated field to Filter and Select True

           

          Selected Parameter "No": Week 29 Excluded

           

           

          Selected Parameter "Yes" : Week 29 Included

           

          Hope it heps

           

          Kindly mark this answer as helpful or correct to close the thread so that it will be helpful for others

          • 2. Re: Leave out Current Week with Calculated Field
            Ritesh Bisht

            Hi Daniel,

             

            This can be achieved  quickly by Set although you have 3 options here ( In,Out and All) which I don't mind (but it depends )

            This is my data-source

             

            Screen Shot 2018-07-16 at 12.23.33 PM.png

             

             

             

            You can make use of Set

             

             

            Screen Shot 2018-07-16 at 12.21.41 PM.png

             

            Conditional Set=

            DATEPART('week', [Order Date])=DATEPART('week' ,TODAY())

            and

            DATEPART('year', [Order Date])=DATEPART('year' ,TODAY())

             

             

            Just right click now and show filter

             

            Screen Shot 2018-07-16 at 12.26.02 PM.png

             

             

            Screen Shot 2018-07-16 at 12.24.49 PM.png

             

             

             

             

            Click In for only current week and All for all the weeks Out for excluding current week

             

             

            Thanks,

            Ritesh

            • 3. Re: Leave out Current Week with Calculated Field
              Daniel Segura

              Hi!


              This really looks like what I need, but at the moment I don't have access to Tableau Desktop, so no, Params or Sets. I'm using Tableau Server (I know...), I'm working on getting it! Is there a way that this can be achieved without parameters?

               

              A coworker has access to Desktop so I can ask him to do it for me !

               

              Thank you so much for being so thorough, this helps a lot!

              • 4. Re: Leave out Current Week with Calculated Field
                Daniel Segura

                Hi Ritesh!

                 

                Sets look like an interesting approach! At the moment, I don't have access to all the features of Tableau Desktop as I'm using Server, I'm requesting a Desktop license . Today I will look for a coworker who has Desktop and will ask him to see how it looks!

                 

                I appreciate you for taking the time to help me out!