Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
powerbi_2022
Frequent 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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.