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
19I have a table with data por ID and sales per month Like this
I need to create a calculated column with average per ID per month for each id like this
I used that but it appears circular dependency.
Average_last_ 3_year =
VAR year_ref =
YEAR ( T_[date])
VAR month_ref =
MONTH ( T_[date])
RETURN
IF (
year_ref - 2
>= MINX ( ALL ( T_[date]), YEAR ( T_[date]) ),
AVERAGEX (
FILTER (
ALLEXCEPT( T_, T[Id]),
YEAR (( T_[date]) ) < year_ref
&& YEAR (( T_[date]) >= year_ref - 3
&& MONTH (( T_[date]) ) = month_ref
),
T_[Valor]
)
)
What is it wrong(**
Solved! Go to Solution.
Hi @Anonymous ,
You need to change your column formula a bit:
Column =
VAR currYear = YEAR ( T[Date] )
VAR currMonth = MONTH ( T[Date] )
VAR currID = T[Id]
RETURN
IF (
currYear - 2 > MINX ( ALL ( T ), YEAR ( T[Date] ) ),
AVERAGEX (
FILTER (
T,
T[Id] = currID
&& YEAR ( T[Date] ) < currYear
&& YEAR ( T[Date] ) >= currYear - 3
&& MONTH ( T[Date] ) = currMonth
),
T[Value]
)
)If this post helps, then please consider Accept it as the solution ✔️to help the other members find it more quickly.
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.
Check out my latest demo report in the data story gallery.
Stand with Ukraine!
Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/
Thank you!
Hi @Anonymous ,
You need to change your column formula a bit:
Column =
VAR currYear = YEAR ( T[Date] )
VAR currMonth = MONTH ( T[Date] )
VAR currID = T[Id]
RETURN
IF (
currYear - 2 > MINX ( ALL ( T ), YEAR ( T[Date] ) ),
AVERAGEX (
FILTER (
T,
T[Id] = currID
&& YEAR ( T[Date] ) < currYear
&& YEAR ( T[Date] ) >= currYear - 3
&& MONTH ( T[Date] ) = currMonth
),
T[Value]
)
)If this post helps, then please consider Accept it as the solution ✔️to help the other members find it more quickly.
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.
Check out my latest demo report in the data story gallery.
Stand with Ukraine!
Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/
Thank you!
@Anonymous , Try a new column like
New column =
var _month = month([Date])
var _id = [id]
return
averagex(filter(Table, [id]=_id && month([Date]) =_month ), [value])
I need to calculate the average using always data from last 3 years.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 38 | |
| 37 | |
| 28 | |
| 28 |
| User | Count |
|---|---|
| 124 | |
| 89 | |
| 73 | |
| 66 | |
| 65 |