4 Replies Latest reply on Jun 27, 2019 4:45 PM by Lauren Bearden

    Normal function vs Window Function

    Rahul Panday

      Hi All ,

       

      I am confused with normal function vs window function eg.

       

      Avg(sales) vs window_Avg (sum(sales )) or window_Avg( sum(sales ),-2,0))

       

      Can you guys please explain ..when we should decide whether to use normal function() or window_fuction (),eg Avg(sales) vs window_Avg(sum(sales))

       

      Thank you

       

      regards ,

      Rahul

        • 1. Re: Normal function vs Window Function
          Lauren Bearden

          Hi Rahul,

           

          A regular aggregation (like sum or average) will take the aggregation of all the rows in your data source. If you have 3 rows, Tableau will simply take the average of those 3 rows.

           

          Now, let's say you have a more advanced problem. You want to find the average of the sum of certain categories (2 pass aggregation, or an aggregation based on an aggregate). This is where you could use a function like WINDOW_AVG. The window functions will take into account only what's in the view, and aggregate based on those number. This comes in handy when you have something like the sum of sales for a certain dimension, but then want to find the average sales across the dimension. You could use a WINDOW_AVG.

           

          You can read more about window calculations if you scroll down in this page. You can read more about other ways to do two pass aggregation here. <link removed>

           

          EDIT by Patrick Byrne (Community Manager): Link was removed as it linked to a dead site.

          6 of 6 people found this helpful
          • 2. Re: Normal function vs Window Function
            Steve Martin

            Hi Rahul,

             

            In addition to Lauren's response I just wanted to clarify her point of: "will take the aggregation of all the rows in your data source"  This means your filtered data-source so if you have specific calculations or filtering in place, then the regular aggregation will run against the final filtered set.

             

            Steve

            1 of 1 people found this helpful
            • 3. Re: Normal function vs Window Function
              Rahul Panday

              Thank you Michael ...it helped to understand .

               

              On Thu, Feb 11, 2016 at 6:36 PM, Michael Hesser <