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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Sofia_A
New Member

How do I remove a year that doesn't have data in power BI while calculating YoY growth

Growth will be calculated from 2020 to 2022 as there was no sales in 2021

Sofia_A_0-1699209228118.png

 

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @Sofia_A ,


Not sure if i fully get you. Supposing you have a data table like:

FreemanZ_2-1699237813280.png


you may try:
1) create a dates table like:

dates = ADDCOLUMNS( CALENDARAUTO(), "Year", YEAR([date]) )

2) relate the dates[date] with data[date] with 1:M relationship.
3) try to plot at table visual with dates[Year] column and a measure like:

 

AmtPY = 
VAR _lastrecordday =
MAXX(
    FILTER(
        ALL(data),
        data[date]<MIN(dates[date])
    ),
data[Date]
)
VAR _result =
SUMX(
    FILTER(
        ALL(data),
        YEAR(data[date]) = YEAR(_lastrecordday)
    ),
    data[Amt]
)
RETURN COALESCE(_result, 0)

 

 

it worked like:

FreemanZ_0-1699238106563.png

 

 

View solution in original post

1 REPLY 1
FreemanZ
Super User
Super User

hi @Sofia_A ,


Not sure if i fully get you. Supposing you have a data table like:

FreemanZ_2-1699237813280.png


you may try:
1) create a dates table like:

dates = ADDCOLUMNS( CALENDARAUTO(), "Year", YEAR([date]) )

2) relate the dates[date] with data[date] with 1:M relationship.
3) try to plot at table visual with dates[Year] column and a measure like:

 

AmtPY = 
VAR _lastrecordday =
MAXX(
    FILTER(
        ALL(data),
        data[date]<MIN(dates[date])
    ),
data[Date]
)
VAR _result =
SUMX(
    FILTER(
        ALL(data),
        YEAR(data[date]) = YEAR(_lastrecordday)
    ),
    data[Amt]
)
RETURN COALESCE(_result, 0)

 

 

it worked like:

FreemanZ_0-1699238106563.png

 

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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