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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
DrewInTheData
Frequent Visitor

A Type of Year Over Year Comparison

Hello!  I didn't know if this should be posted in DAX, but I feel like it will require DAX.  So I'm working with yield data from types of corn and soybeans.  I have 1 table that has each season, crop type, hybrids (types of corn and soybeans), their avg. yield and the amount of acres planted with those hybrids.  I created this table in a separate database with SQL and imported it into Power BI.

 

What I'm trying to achieve would use these three columns of data: 

 

DrewInTheData_0-1691681035098.png

 

What i'm specifically looking for is to create a comparison of year over year avg. yield changes for the hybrids if they happened to be planted over multiple years.  This will not always be the case.  An example would be if '13G519' was planted in 2022 and 2021, would would the comparison be in the avg. yield from year to year?  How could this be handled if a hybrid was planted in more than two years? 

 

I know this will probably not be a difficult solution, but I couldn't find any similar examples that would condense 1 item down to a YOY comparison.  Thank you in advance for your assistance.

2 REPLIES 2
johnt75
Super User
Super User

First create a proper date table, marked as a date table, and link that to your fact table. If the relationship ends up being many-to-many change it so that it is single direction with Date filtering the fact table. Use columns from your date table in your visuals.

You can then write a measure like

Yield YoY % =
VAR CurrentAvg =
    AVERAGE ( 'Table'[avg_yield] )
VAR PrevAvg =
    CALCULATE ( AVERAGE ( 'Table'[avg_yield] ), DATEADD ( 'Date'[Date], -1, YEAR ) )
VAR Result =
    DIVIDE ( CurrentAvg - PrevAvg, PrevAvg )
RETURN
    Result

So since I'm only dealing with years, the table format won't allow me to set as Date as it changes all the years to 1905.  Thus, I cannot "Mark as date table".

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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