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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
alaynanich
Helper I
Helper I

Calculate YOY by ignoring the lowest granularity?

Hi PBI community,

 

So I have some sales data that comes in the below format. The Periods TY and LY means "This Year" and "Last Year", and I'm trying to find the YOY sales. The measure usually works but I think the transaction ID is confusing PBI and it's not calculating the difference. Is there any way to edit my DAX to ignore transaction id and get yoy for the skus? I only need transactions for distinct counts (my real data has a product hierarchy assoaciated with the sku so i need distinct counts and YOY sales for those too).

Sales YOY =
var ty = CALCULATE(SUM('Table'[sales]),'Table'[Period]="TY")
var ly = CALCULATE(SUM('Table'[sales]),'Table'[Period]="LY")
RETURN ty-ly
 

alaynanich_1-1716589219497.png

 

alaynanich_2-1716589244064.png

 

1 ACCEPTED SOLUTION
xifeng_L
Super User
Super User

Hi @alaynanich ,

 

You can refer to below column expression.

 

xifeng_L_0-1716610151962.png

 

But I think it would be more accurate to use a measure to calculate YOY instead of calculated column, since the calculated column is static.

 

xifeng_L_1-1716610178878.png

 

Sales YOY (Measure) = 
var ty = CALCULATE(SUM('Table'[sales]),'Table'[Period]="TY")
var ly = CALCULATE(SUM('Table'[sales]),'Table'[Period]="LY")
RETURN ty-ly

 

 

Demo - Calculate YOY by ignoring the lowest granularity.pbix

 

 

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

 

 

View solution in original post

3 REPLIES 3
xifeng_L
Super User
Super User

Hi @alaynanich ,

 

You can refer to below column expression.

 

xifeng_L_0-1716610151962.png

 

But I think it would be more accurate to use a measure to calculate YOY instead of calculated column, since the calculated column is static.

 

xifeng_L_1-1716610178878.png

 

Sales YOY (Measure) = 
var ty = CALCULATE(SUM('Table'[sales]),'Table'[Period]="TY")
var ly = CALCULATE(SUM('Table'[sales]),'Table'[Period]="LY")
RETURN ty-ly

 

 

Demo - Calculate YOY by ignoring the lowest granularity.pbix

 

 

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

 

 

Thank you! I think there was osmething wrong with my data model so now my original calculation is working, but appreciate your response!! Noted about the columns vs measures

alaynanich
Helper I
Helper I

can't seem to upload files so here's a copy of the sample data
PeriodMonthstore idtranssku #sales_typesalesunitsgpSales YOY

LYFEB18175181752023-02-24 00:00:0055115493640371online6.9911.56-6.99
LYFEB11577115772023-02-24 00:00:0057511251882562online220.04-2
LYFEB11577115772023-02-24 00:00:0057611113954383online110.02-1
TYFEB14296142962024-02-24 00:00:00460154152163714online19.9917.0819.99
LYFEB14296142962024-02-24 00:00:0026015525439984online39.98214.15-39.98
LYFEB15483154832023-02-12 00:00:0011212145584305retail27.9914.7-27.99
TYFEB17448174482024-02-26 00:00:005871113266496retail6.4911.546.49
LYFEB17749177492024-02-08 00:00:0015514361015587retail8.9913.04-8.99
TYFEB17749177492024-02-08 00:00:0015313094515587retail8.9913.048.99
TYFEB17353173532024-02-23 00:00:002047083325168retail25.1649.4925.16

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.

Top Solution Authors