cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
powerbi_2022
Regular Visitor

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 5
v-kkf-msft
Community Support
Community 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].

 

vkkfmsft_0-1643875948669.png  vkkfmsft_1-1643876047601.png

 

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.

 

 

 

jdbuchanan71
Super User
Super User

It returns for me based on your sample data.

 

jdbuchanan71_0-1643465892302.png

 

jdbuchanan71
Super User
Super User

You could try it like this.

PY Salary = 
VAR _Year = SELECTEDVALUE ('Table'[Year] )
RETURN
CALCULATE ( SUM ('Table'[Salary] ),'Table'[Year] = _Year - 1 )

Not returning any value.

VijayP
Super User
Super User

@powerbi_2022 
This thread may help you !https://blog.crossjoin.co.uk/2010/05/26/time-intelligence-without-date-columns-in-dax/




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors