The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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:
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.
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".
User | Count |
---|---|
17 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
12 | |
9 | |
8 |