3 Replies Latest reply on Aug 11, 2017 7:36 AM by varun H

    Restrict data on a chart

    varun H

      Hi

       

      I'm a newbie , just started working on tableau. need help with below query.

      Question: I have a report which will have a parameter ( Daily , weekly , Monthly ) and based on the selection , bar chart below changes axis.

      eg: if user selects daily then only current week data gets displayed . If weekly then last 4 weeks data , and if monthly then last 3 months data.

       

      Thanks

        • 1. Re: Restrict data on a chart
          Jim Dehner

          Yes this is all possible - please attach your TWBX workbook to show use where you are in your calculations -

          Thanks

          Jim

          Packaged workbooks: when, why, how

          • 2. Re: Restrict data on a chart
            Galen Busch

            Hi Varun,

             

            Because there are different "filters" for each of your date parts (day, week, month) as well as date parts, you'll need 3 components.

             

            1. Your parameter - it will have 3 values - "Daily", "Weekly", "Monthly'

             

             

            2. A dynamic date field to drive the axis-
            Case [Parameter]
            When "Daily" then datepart('day',[Date])
            When "Weekly" then datepart('week',[Date])
            When "Monthly" then datepart('month',[Date])
            END

             

            3. A filter the restricts the scope -

            [Parameter] = "Daily" and [Date] > dateadd('day',{MAX([Date])},-8)

            OR
            [Parameter] = "Weekly" and [Date] > dateadd('week',{MAX([Date])},-5)
            OR

            [Parameter] = "Monthly" and [Date] > dateadd('month',{MAX([Date])},-4)

            • 3. Re: Restrict data on a chart
              varun H

              Hey Galen

               

              Thanks for the reply.

               

              it worked but still not getting what i want exactly.

               

              Actually i have order date and sum(measure) , so when user selects "Monthly" i want to have only 3 months bar in the chart ( showing monthly total ) , if "weekly" then only 4 bars and days then only 7 bars ( as per current week).

               

              Is there anything i'm missing?