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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Using Previous Row Value in formula

I have two tables. FactsVehicleYearly:

 

FactsVehicleYearly.png

 

Facts1:

 

Facts1.png

 

 

 

I have created a measure in Facts1 (as seen in the formula bar of the previous image) to use in my formula in the FactsVehiclesYearly table. I am trying to calculate a YOY Fuel value for each row in the FactsVehicleYearly table. Here is the formula below:

 

 

YOY Fuel Economy Rate with Degradation (MPG) = IF(FactsVehicleYearly[Year] = 1, RELATED(FactsVehicle[Fuel Economy Rate])*(1-Fact1[M_Annual Fuel Degradation]), I NEED HELP HERE)

 

If Year is not equal to one, the formula should go something like this:

Previous YOY Fuel Economy Rate with Degradation * (1-Fact1[M_Annual Fuel Degradation])

 

I'm stuck on how to get the previous YOY Fuel value. Any ideas?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I was able to get around my issue by using the following formula in my calculated column:

 

YOY Fuel Economy Rate with Degradation (MPG) =
Var One = RELATED(FactsVehicle[Fuel Economy Rate]) * (1-Fact1[M_Annual Fuel Degradation])
Var Two = One * (1-Fact1[M_Annual Fuel Degradation])
Var Three = Two * (1-Fact1[M_Annual Fuel Degradation])
Var Four = Three * (1-Fact1[M_Annual Fuel Degradation])
Var Five = Four * (1-Fact1[M_Annual Fuel Degradation])
Var Six = Five * (1-Fact1[M_Annual Fuel Degradation])
Var Seven = Six * (1-Fact1[M_Annual Fuel Degradation])
Var Eight = Seven * (1-Fact1[M_Annual Fuel Degradation])
Var Nine = Eight * (1-Fact1[M_Annual Fuel Degradation])
Var Ten = Nine * (1-Fact1[M_Annual Fuel Degradation])
RETURN
SWITCH(FactsVehicleYearly[Year],
1, One, 2, Two, 3, Three, 4, Four, 5, Five, 6, Six, 7, Seven, 8, Eight, 9, Nine, 10, Ten, 0)

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

I was able to get around my issue by using the following formula in my calculated column:

 

YOY Fuel Economy Rate with Degradation (MPG) =
Var One = RELATED(FactsVehicle[Fuel Economy Rate]) * (1-Fact1[M_Annual Fuel Degradation])
Var Two = One * (1-Fact1[M_Annual Fuel Degradation])
Var Three = Two * (1-Fact1[M_Annual Fuel Degradation])
Var Four = Three * (1-Fact1[M_Annual Fuel Degradation])
Var Five = Four * (1-Fact1[M_Annual Fuel Degradation])
Var Six = Five * (1-Fact1[M_Annual Fuel Degradation])
Var Seven = Six * (1-Fact1[M_Annual Fuel Degradation])
Var Eight = Seven * (1-Fact1[M_Annual Fuel Degradation])
Var Nine = Eight * (1-Fact1[M_Annual Fuel Degradation])
Var Ten = Nine * (1-Fact1[M_Annual Fuel Degradation])
RETURN
SWITCH(FactsVehicleYearly[Year],
1, One, 2, Two, 3, Three, 4, Four, 5, Five, 6, Six, 7, Seven, 8, Eight, 9, Nine, 10, Ten, 0)

Greg_Deckler
Community Champion
Community Champion

So, take a look at my quick measure here: https://community.powerbi.com/t5/Quick-Measures-Gallery/Week-Ending/m-p/389293

 

I realize it is a completely different issue, but I believe it demonstrates the basic technique you will need to use. Note where I am accounting for things happening in different years (week spans years)



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks for the info. How am I going to get around my circular dependency issue (since I am trying to pull a value from the same column my formula is in)?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.