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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Anonymous
Not applicable

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  @Anonymous ,

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  @Anonymous ,

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
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.