Forum Discussion
Measure does not work when applied as calculated column formula
Hi,
I have a simple table :
I need to add a column that contains sales of the previous year. I can easily calculate it with a measure like this:
Amount previous year =
CALCULATE( sum ( tSales[Sales] ),
FILTER( ALL(tSales), tSales[Year] = MAX( tSales[Year]) - 1 )
)
gvg try this for calculated column
Prev Year = VAR __prevYear = Sales[Year] - 1 RETURN CALCULATE ( SUM ( Sales[Amount] ), ALL ( Sales ), Sales[Year] = __prevYear )Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
2 Replies
- parry2kSuper User
gvg try this for calculated column
Prev Year = VAR __prevYear = Sales[Year] - 1 RETURN CALCULATE ( SUM ( Sales[Amount] ), ALL ( Sales ), Sales[Year] = __prevYear )Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
- gvgPost Prodigy
Yep, that works. Than you. Why it works with a variable and not working with my measure?