Forum Discussion

janetcpa's avatar
janetcpa
Frequent Visitor
5 years ago
Solved

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 ...
  • AlB's avatar
    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.