4 Replies Latest reply on Oct 29, 2017 9:06 AM by Jim Dehner

    Dynamic Parameter

    Roisha Pal

      Hi Guys,

       

      In my attached workbook I have created calculated YTD Sales and Current Month Sales. I want to create a parameter such a way when user select YTD he should be able to see YTD Sales if he selects Current Month Sales he should be able to see Current Month Sales.

        • 1. Re: Dynamic Parameter
          Norbert Maijoor

          Hi Roisha,

           

          Find my approach based on sheet-selection as reference below and stored in attached workbook version 10.3 located in the original thread

           

           

          1. MTD: datediff("month",[Order Date],#29-10-2016#)=0 and [Order Date]<#29-10-2016#  ps. replace #29-10-2016# by today() when your dataset contains current year data

           

          2. Define parameter MTD/YTD

           

           

          3. Define calculated field Display: MTD/YTD based on parameter defined. Sheets selection in tableau is explained here

           

          4. Drag required objects to the indicated locations on the MTD sheet and set MTD to TRUE

           

           

          5. Define calculated field YTD: datediff("year",[Order Date],#29-10-2016#)=0 and [Order Date]<#29-10-2016#

           

          6. Drag required objects to the indicated locations on the YTD sheet and set YTD to TRUE

           

           

          Regards,

          Norbert

          • 2. Re: Dynamic Parameter
            Jim Dehner

            Hi there are several ways to do this but see below for one

             

            First your data set does not include any sales data for 2017 so I created a field called [ Today() JD ] and set it equal to 12/31/2016 as a substitute

            I created a parameter for the switch as shown

             

             

            Then your Current Month calculation becomes

             

            and your YTD becomes

             

             

            Your Viz looks like this for YTD

             

             

            And this for Current

             

             

            I am on a different version of tableau an you could not open the workbook - sorry

             

            Jim

             

            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.

            1 of 1 people found this helpful
            • 3. Re: Dynamic Parameter
              Shinichiro Murakami

              Hi Roisha

               

              Here you go.

               

              To adjust calendar to updated. I added order date mod.

               

              Create parameter.

               

              Avoid other year's same month

               

               

              Here is a dynamic calc field.

               

               

               

               

               

               

              Thanks,

              Shin

              • 4. Re: Dynamic Parameter
                Jim Dehner

                Glad to help out

                Thanks

                Jim