The WINDOW_AVG() function in Tableau is a table calculation function that calculates the average of a field or expression within a specified window or range. It provides the average value of the data points within the defined window.
The syntax for the WINDOW_AVG() function in Tableau is as follows:
WINDOW_AVG([expression], [start, end])
- [expression] (optional): The field or calculation for which you want to calculate the average. If not specified, it calculates the average of all records within the window.
- [start] (optional): The starting point of the window. If not specified, the window starts from the first data point.
- [end] (optional): The ending point of the window. If not specified, the window ends at the current data point.
Here's an example to demonstrate how to use the WINDOW_AVG() function in Tableau:
Suppose you have a dataset that contains information about the monthly sales of different products. You want to calculate the average monthly sales within a rolling three-month window.
- Open Tableau and connect to your dataset.
- Create a view that includes the "Date" field and the "Sales" field.
- Right-click on an empty space in the view and select "Create Calculated Field."
- In the calculation editor, enter the following formula:
WINDOW_AVG(SUM([Sales]))
This formula calculates the average of the aggregated sales within the window.- Click "OK" to create the calculated field.
- Drag the calculated field to the view.
Tableau will calculate the average monthly sales within the specified rolling three-month window. It computes the average value of the sales data points that fall within the window for each period.
You can further customize the view, apply sorting, or add additional calculations based on the average. For example, you can create a visualization that shows the trend of the average monthly sales over time or compare the averages across different product categories.
The WINDOW_AVG function allows you to perform calculations related to the average of values within a specified window. It helps you understand the central tendency of the data within the window and supports various data analysis and visualization scenarios.
No comments:
Post a Comment
If you have any doubts. Please let me know