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
millerfdan
Regular Visitor

DAX Help: Trying to calculate YoY change and the predict future costs

Hello,

I’m looking for some help with a DAX issue that I just can’t figure out. This is for a school project, and I’ve been stuck on it for hours.

I’m trying to calculate the Year-over-Year (YoY) growth for different road work costs across various counties (and statewide) in Iowa. Specifically, I want to create a measure that works with the two slicers shown in the attached screenshot, calculating the YoY % change from the previous year (e.g., 2011 compared to 2010, and so on).

After that, I plan to calculate the average yearly change based on that measure to make a prediction for future years (2024, 2025, and beyond)—but I’ll tackle that part later.

The issue is that I cannot get the first measure to work. Everything I’ve tried either:

  1. Returns a random number in the total row and nothing in the individual rows.
  2. Results in a blank column in the table.

I’ve tried using ChatGPT, but it keeps regurgitating the same failing solutions. I’m not sure if the issue is that each year appears multiple times or something else. I even unpivoted the cost columns (Granular Cost, Paved Cost, etc.), but that didn’t resolve it either.

If anyone can help, I would really, really appreciate it. Thanks in advance!

data set cost per mile.pngTable w filters.png

I have attached the dataset and a table showing the two slicers im working with.

 

Thank you.

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

One of ways is to create a star schema data model, like below, and try to use OFFSET DAX function in the measure.

OFFSET function (DAX) - DAX | Microsoft Learn

 

Jihwan_Kim_1-1739852838266.png

 

 

Jihwan_Kim_0-1739852824363.png

 

 

Granular Cost measure: = 
SUM( cost[granular_cost] )

 

OFFSET function (DAX) - DAX | Microsoft Learn

 

Previous year: = 
CALCULATE (
    [Granular Cost measure:],
    OFFSET ( -1, ALL ( 'year'[year] ), ORDERBY ( 'year'[year], ASC ) )
)

 

YoY %: = 
DIVIDE( [Granular Cost measure:] - [Previous year:], [Previous year:] )

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi, @millerfdan 

 

Can you provide example files and the output you expect? This will better help you solve the problem. Please remove any sensitive data in advance.

How to provide sample data in the Power BI Forum - Microsoft Fabric Community

 

Best Regards,

Community Support Team _Charlotte

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

Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

One of ways is to create a star schema data model, like below, and try to use OFFSET DAX function in the measure.

OFFSET function (DAX) - DAX | Microsoft Learn

 

Jihwan_Kim_1-1739852838266.png

 

 

Jihwan_Kim_0-1739852824363.png

 

 

Granular Cost measure: = 
SUM( cost[granular_cost] )

 

OFFSET function (DAX) - DAX | Microsoft Learn

 

Previous year: = 
CALCULATE (
    [Granular Cost measure:],
    OFFSET ( -1, ALL ( 'year'[year] ), ORDERBY ( 'year'[year], ASC ) )
)

 

YoY %: = 
DIVIDE( [Granular Cost measure:] - [Previous year:], [Previous year:] )

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

This works, thank you for the help!

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.