Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
Hi,
I have the following matrix in powerbi with year as columns and values as rows.
Profit is a measure = Revenue - Cost
How do I calculate the profit difference between years and present them as row highlighted in yellow below. Thanks!
Solved! Go to Solution.
Hi @milkywaypowerbi ,
Try this:
Profit Diff =
VAR CurrentYear_ =
MAX ( Sheet1[Year] )
VAR PreviousYear_ =
MAXX ( FILTER ( ALL ( Sheet1[Year] ), Sheet1[Year] < CurrentYear_ ), [Year] )
VAR CurrentProfit_ = [Profit]
VAR PreviousProfit_ =
CALCULATE ( [Profit], FILTER ( ALL ( Sheet1 ), Sheet1[Year] = PreviousYear_ ) )
VAR MinYear_ =
CALCULATE ( MIN ( Sheet1[Year] ), ALL ( Sheet1 ) )
RETURN
IF ( CurrentYear_ <> MinYear_, CurrentProfit_ - PreviousProfit_ )
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @milkywaypowerbi ,
Just create another measure like so:
Profit Diff 2 = SUMX(Sheet1,[Profit Diff])
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@milkywaypowerbi , using seperate date/year table. Use year from that table in visual
This Year = CALCULATE([Profit]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE([Profit],filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))
diff = [This Year]-[Last Year ]
diff % = divide([This Year]-[Last Year ],[Last Year ])
Year on column. Show on Row - True ( to show meausre on row)
Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA
Hi,
Sorry I am a bit confuse by using a separate table. I created another table for year
Here is the link to the powerbi file
:https://drive.google.com/drive/folders/1_iiFNWrVGAyAhHY5hWnSbETcNGygRMYJ?usp=sharing
Can you please help me on the file.
Thank you so much!
Hi @milkywaypowerbi ,
Try this:
Profit Diff =
VAR CurrentYear_ =
MAX ( Sheet1[Year] )
VAR PreviousYear_ =
MAXX ( FILTER ( ALL ( Sheet1[Year] ), Sheet1[Year] < CurrentYear_ ), [Year] )
VAR CurrentProfit_ = [Profit]
VAR PreviousProfit_ =
CALCULATE ( [Profit], FILTER ( ALL ( Sheet1 ), Sheet1[Year] = PreviousYear_ ) )
VAR MinYear_ =
CALCULATE ( MIN ( Sheet1[Year] ), ALL ( Sheet1 ) )
RETURN
IF ( CurrentYear_ <> MinYear_, CurrentProfit_ - PreviousProfit_ )
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
Thank you so much!
However, the total column is not displaying right total difference. I would like a sum of the difference. Can you assist with that?
Hi @milkywaypowerbi ,
Just create another measure like so:
Profit Diff 2 = SUMX(Sheet1,[Profit Diff])
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you so much!
@milkywaypowerbi , whenever we create time intelligence we prefer a separate table like a date table joined with date of the table if you have data only at year level a year table joined on year.
Hi @amitchandak
I have created another table for the year but the codes are different from my naming so I am getting errors since I am unsure is it referring to the year in revenue sheet or date
Can you please assist with my table names? Thanks!
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.