Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi,
I have a Tableau expression that I would like to convert into DAX.
PREVIOUS_VALUE(0)+
MIN(
WINDOW_AVG(SUM([values]),-365-[Days Average],-365+[Days Average]),
WINDOW_AVG(SUM([values]),-730-[Days Average],-730+[Days Average])
)
Hi, @MAwwad ,
1) In the first part of the query I get the following error message:
"The first argument of EARLIER/EARLIEST is not a valid column reference in the earlier row context.", - related to this row, MAX('Table'[Date]) = EARLIER(MAX('Table'[Date])) .
2) Also, I am not sure whwther WINDOWAVG function is avaialble, unless it is possible to combine WINDOW and AVERAGE somehow?
Hello!
Regarding your first question, the error message suggests that the column reference 'Table'[Date] is not valid in the context of the EARLIER function. This can happen if the EARLIER function is being used in a calculated column, and the column reference is not part of the column being calculated.
To resolve this issue, you can try using a measure instead of a calculated column, which allows you to refer to columns outside of the current row context. You can define a measure using the CALCULATE function, and then use the MAXX function to calculate the maximum date within the current filter context. Here's an example:
This measure calculates the maximum date for each category in the 'Table' table, by filtering the table to only include rows with the same category as the current row context.
Regarding your second question, the WINDOWAVG function is not a built-in function in DAX. However, you can use the AVERAGEX function along with a FILTER function to calculate a moving average over a specified window of rows. Here's an example:
This measure calculates a 7-day moving average for the 'Value' column in the 'Table' table, by filtering the table to include only rows with a date within the last 7 days, relative to the current row context.
I hope this helps! Let me know if you have any further questions.
Cumulative Rolling Average =
VAR PrevValue =
CALCULATE(
SUM([values]),
FILTER(
ALLSELECTED(),
MAX('Table'[Date]) = EARLIER(MAX('Table'[Date]))
)
)
RETURN
PrevValue +
MINX(
{
CALCULATE(
WINDOWAVG(SUM([values]), -365 - [Days Average], -365 + [Days Average])
),
CALCULATE(
WINDOWAVG(SUM([values]), -730 - [Days Average], -730 + [Days Average])
)
},
[Cumulative Rolling Average]
)
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 20 | |
| 11 | |
| 10 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 34 | |
| 31 | |
| 19 | |
| 12 | |
| 11 |