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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
daniel0920bu
New Member

YoY in incompleted year

Hi - 

 

Here is my expected result. 

 

DateSumSum (last year)YoY diff
2019 Jun150--
2020 Jun100150-50
2021 Jun120100+20
2022 (Apr)80120-40

 

My question is that how to create a measure to calculate YoY differences for 2022 when the year isn't completed yet? If I use dateadd/sameperiodlastyear function, power bi could only compare the value of 2021 Apr, which this data is absent (and it is not what I want).

 

Thanks a lot for your help!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @daniel0920bu ,

I created some data:

vyangliumsft_0-1649143876919.png

Here are the steps you can follow:

1. Create measure.

Flag =
var _1=MAXX(FILTER(ALL('Table'),YEAR('Table'[Date])=YEAR(MAX('Table'[Date]))),[Date])
return
IF(
    MONTH(MAX('Table'[Date]))=MONTH(_1),1,0)
Sum =
SUMX(FILTER(ALL('Table'),YEAR('Table'[Date])=YEAR(MAX('Table'[Date]))&&'Table'[Date]<=MAX('Table'[Date])),[amount])
Sum (last year) =
SUMX(FILTER(ALL('Table'),YEAR('Table'[Date])=YEAR(MAX('Table'[Date]))-1&&'Table'[Date]<=MAX('Table'[Date])),[amount])
YoY diff =
IF(
    [Sum (last year)]=BLANK(),BLANK(),
[Sum] - [Sum (last year)])

2. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_1-1649143876920.png

3. Result:

When the last date is 2022.4:

vyangliumsft_2-1649143876921.png

Add a row of data for 2022.5 and the last date as 2022.5:

The results also change with the date:

vyangliumsft_3-1649143876921.png

Please click here for the pbix file

 

Best Regards,

Liu Yang

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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi  @daniel0920bu ,

I created some data:

vyangliumsft_0-1649143876919.png

Here are the steps you can follow:

1. Create measure.

Flag =
var _1=MAXX(FILTER(ALL('Table'),YEAR('Table'[Date])=YEAR(MAX('Table'[Date]))),[Date])
return
IF(
    MONTH(MAX('Table'[Date]))=MONTH(_1),1,0)
Sum =
SUMX(FILTER(ALL('Table'),YEAR('Table'[Date])=YEAR(MAX('Table'[Date]))&&'Table'[Date]<=MAX('Table'[Date])),[amount])
Sum (last year) =
SUMX(FILTER(ALL('Table'),YEAR('Table'[Date])=YEAR(MAX('Table'[Date]))-1&&'Table'[Date]<=MAX('Table'[Date])),[amount])
YoY diff =
IF(
    [Sum (last year)]=BLANK(),BLANK(),
[Sum] - [Sum (last year)])

2. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_1-1649143876920.png

3. Result:

When the last date is 2022.4:

vyangliumsft_2-1649143876921.png

Add a row of data for 2022.5 and the last date as 2022.5:

The results also change with the date:

vyangliumsft_3-1649143876921.png

Please click here for the pbix file

 

Best Regards,

Liu Yang

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

johnt75
Super User
Super User

You can create a measure like

YOY Diff =
var currentDate = MAX('Date'[Date])
var lastYearTotal = CALCULATE( [Total measure], REMOVEFILTERS('Date'), 'Date'[Year] = YEAR(currentDate) - 1)
var currentYearTotal = [Total measure]
return currentYearTotal - lastYearTotal

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors