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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Year to year difference

How do i calculate year to year diffrence if my data type is in a whole number and not in "date" datatype. I only have sales data for 2021 and 2022. There are no month and day data. Most of tutorial/solution that I watch use calendar(dim date). But in my case I used only years data only which is in whole number datatype.

 

2 REPLIES 2
FreemanZ
Super User
Super User

or you plot a table visual with the year column and a measure like:

YoY Measure = 
VAR _salespre = 
MAXX(
    FILTER(
        ALL(data),
        data[Year]=MAX(data[Year])-1
    ),
    data[Sales]
)
RETURN
IF(
    _salespre<>BLANK(),
    MAX(data[Sales])-_salespre,
    ""
)

it worked like:

FreemanZ_1-1683459078971.png

FreemanZ
Super User
Super User

hi @Anonymous 

supposing you have a table like:

YearSales
20206
20218
20229
20238

 

try to add a calculated column like:

 

YoY = 
VAR _salespre = 
MAXX(
    FILTER(
        data,
        data[Year]=EARLIER(data[Year])-1
    ),
    data[Sales]
)
RETURN
IF(
    _salespre<>BLANK(),
    [Sales]-_salespre
)

 

it worked like:

FreemanZ_0-1683458914220.png

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.

Users online (6,054)