Forum Discussion

powerbi_2022's avatar
powerbi_2022
Frequent Visitor
4 years ago

How to get Previous Year Aggregate Values

I need to take Aggregated Salary values for Previous year where Year Column is not Date column -

              

 

Employee_IDYearMonthSalary
12311300
12312100
12313200
12326250
12328250
12329250

 

Output Expected -

Employee_IDYearSalaryPrevious Year Salary
1231600 
1232750600

5 Replies

  • You could try it like this.

    PY Salary = 
    VAR _Year = SELECTEDVALUE ('Table'[Year] )
    RETURN
    CALCULATE ( SUM ('Table'[Salary] ),'Table'[Year] = _Year - 1 )
  • v-kkf-msft's avatar
    v-kkf-msft
    Icon for Community Support rankCommunity Support

    Hi powerbi_2022 ,

     

    In this visual, is the [Year] column in the same table as the [Salary] column (i.e. 'Table')? If it is in the same table then the formula of jdbuchanan71  will return the correct value, if it is not in the same table then replace "Table" with the table where the [Year] column is located.

    For example in my model, I need to use 'Date'[YearNum].

     

      

     

    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
    Best Regards,
    Winniz
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.