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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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

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.

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

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

v-jayw-msft
Community Support
Community Support

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.

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

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

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.

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
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
September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.