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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Prasala583
Frequent Visitor

How Can i do this "For Each Year I need to get the previous Year Values"

Hello All,

I need help with this scenario

I have a Table

KPI_IDProgram_IDDateValues
KP1P101-01-201723
KP2P101-01-201825
KP3P201-01-201715
KP4P201-01-201845
KP5P201-01-201985
KP6P301-01-201765
KP7P301-01-201825
KP8P401-01-201745
KP9P401-01-201710

 

now i have to generate a line chart comparing previous year and the next year values

like this

 

KPI_IDProgram_IDDateValuesprevious Dateprevious Values
KP1P101-01-201723  
KP2P101-01-20182501-01-201723
KP3P201-01-201715  
KP4P201-01-20184501-01-201715
KP5P201-01-20198501-01-201845
KP6P301-01-201765  
KP7P301-01-20182501-01-201765
KP8P401-01-201745  
KP9P401-01-20181001-01-201745
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Prasala583 ,

 

Check the formula and the result as below.

Column = CALCULATE(SUM('Table'[value]),FILTER(ALLEXCEPT('Table','Table'[PM_ID]),MONTH('Table'[Month])=MONTH(EARLIER('Table'[Month]))&&YEAR('Table'[Month])=YEAR(EARLIER('Table'[Month]))-1))

3.PNG

 

Best Regards,

Jay

 

Community Support Team _ Jay Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

8 REPLIES 8
harshnathani
Community Champion
Community Champion

Hi @Prasala583 ,

 

 

Please create 2 Calculated Columns

 

Previous Date = CALCULATE(
MAX(Table1[Date]),FILTER(ALLEXCEPT(Table1,Table1[Program_ID]), Table1[Date] < EARLIER(Table1[Date])))
 
 
Previous Values = CALCULATE(
MAX(Table1[Values]),FILTER(ALLEXCEPT(Table1,Table1[Program_ID]), Table1[Date] < EARLIER(Table1[Date])))
 
 
123.JPG
 
 
Regards,
Harsh Nathani
 
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!!
 
 

Hello there,

 

Thanks for the reponds

 

the only issue i am getting is the SUM value

i am always getting the SUM value not the individual values

 

@Prasala583 ,

 

1.jpg

 

Make sure that the column is Don't Summarize.

 

Regards,

Harsh Nathani

Anonymous
Not applicable

Hi @Prasala583 ,

 

Please check the formula as below, it should help get the value you want then put it to line chart.

Column = CALCULATE(SUM('Table'[Values]),FILTER('Table',YEAR('Table'[Date])=YEAR(EARLIER('Table'[Date]))-1&&'Table'[Program_ID]=EARLIER('Table'[Program_ID])))

1.PNG

 

Best Regards,

Jay

 

Community Support Team _ Jay Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi thanks for the responds

but i am getting an error while implementing the exact formula

can you help me with this

 

i am not getting the exact values but the sum value

 

image001.jpg

Anonymous
Not applicable

Hi @Prasala583 ,

 

Check the formula and the result as below.

Column = CALCULATE(SUM('Table'[value]),FILTER(ALLEXCEPT('Table','Table'[PM_ID]),MONTH('Table'[Month])=MONTH(EARLIER('Table'[Month]))&&YEAR('Table'[Month])=YEAR(EARLIER('Table'[Month]))-1))

3.PNG

 

Best Regards,

Jay

 

Community Support Team _ Jay Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi @Prasala583 ,

 

I see you have duplicate PROGRAM_METRIC_ID in your table in same year. So you want the value group by month and PROGRAM_METRIC_ID instead of by year and PROGRAM_METRIC_ID? What's the expect out put in your visual?

 

Best Regards,

Jay

Greg_Deckler
Super User
Super User

Your logic for the previous date is not obvious to me but you will need to use the technique found here: See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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