2 Replies Latest reply on May 4, 2017 7:43 AM by Michael Someck

    Change filter default to current week when new data is added?

    Erica Ram

      Hello all, I have a viz that is updated weekly with new data from the previous week. The Weeks are integer values 1, 2, 3, etc. I'm looking to see if there is a way to make the filter default change so that when the new data is added, the filter defaults to the most recent week. For example, when the data refreshes for Week 4, the Week dropdown filter defaults to 4 instead of 3 (previous week). Thanks in advance.

        • 1. Re: Change filter default to current week when new data is added?
          Zhouyi Zhang

          Hi, Erica

           

          Why not use a calculation field to default the data for previous week as below:

           

          [your date field] < datetrunc('week',today())

          and

          [your date field] >= dateadd('week',-1, datetrunc('week',today()))

           

          and put this as filter.

           

          ZZ

          • 2. Re: Change filter default to current week when new data is added?
            Michael Someck

            Hi Erica,

             

            Another option would be to identify the max week number in the dataset with a LOD calculation and use it to filter the data. You can create a calculated field with formula

             

            [Week] = {FIXED : MAX([Week])}

             

            You can then drag this to the filter shelf and filter only true values. The downside here is that this fixes your viz to the most recent week: you won't be able to select a previous week's data. If you wanted to have that option, you could use some combination of parameters and filters.

             

            For example, you could create a boolean parameter called "Week Selection" where true is "Most Recent Week" and false is "Other". You could then create a calculated field like

             

            ([Week Selection] AND [Week] = {FIXED : MAX([Week])})

            OR

            NOT [Week Selection]

             

            Effectively what this does is it filters out everything except to most recent week when you select so from the parameter. If you select "Other", the calculated field won't filter anything (it returns true for everything), so whatever you have in your week filter will be all that is taken into account.

             

            Does that help?

             

            Michael