Forum Discussion
janetcpa
5 years agoFrequent Visitor
Calculated Columns using one year average and not calculating if prior year is missing
I have over 30,000 observations of annual financial data dating from 2010 to 2020 that I want to use with my students. I have a very short example below. We calculate Return on Equity (ROE) as Net ...
- 5 years ago
Hi janetcpa
You're not dividing by 2 for the average equity in the sample data shown. Add the division by 2 if necessary here:
Avg Equity = VAR previousYear_ = CALCULATE ( MAX ( Table1[Fiscal Year] ), Table1[Fiscal Year] < EARLIER ( Table1[Fiscal Year] ), ALLEXCEPT ( Table1, Table1[Global Company Key] ) ) RETURN IF ( NOT ISBLANK ( previousYear_ ), Table1[Equity] + CALCULATE ( SUM ( Table1[Equity] ), Table1[Fiscal Year] = previousYear_, ALLEXCEPT ( Table1, Table1[Global Company Key] ) ) )ROE = IF ( Table1[Avg Equity] > 0, DIVIDE ( Table1[Net Income (Loss)], Table1[Avg Equity] ) )Please accept the solution when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
janetcpa
5 years agoFrequent Visitor
Thanks - that worked great! I did forget to divide by 2 and added that to the code and everything works great. Thanks so much!
(Note that I can now show my students the difference in overall ROE if they do it as a calculated column versus as a measure and how they need to think through this as you get REALLY different overall results with each one).