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 September 15. Request your voucher.

Reply
TCavins
Helper V
Helper V

Table % Change from Previous Row

I have a simple table that has 2 columns.

 

Year

SUM Units

 

I would like to add a third column that gets the % Change of Sum Units for each row compared to the previous year. I'm likely overthinking the DAX. Can someone help provide the correct DAX to get this? The years could be in order, they could just be 2020 and 2024.

1 ACCEPTED SOLUTION
TCavins
Helper V
Helper V

Here's the solution I developed combining various sources I found. It may not be the most condensed but it works:

Units % Changed = 
VAR CurrentRowDate = MAX(MYTABLE[Year])
var currentUnits = CALCULATE(
                                SUM(MYTABLE[Units]),
                                FILTER(
                                    ALLSELECTED(MYTABLE),
                                    MYTABLE[Year] = CurrentRowDate))

VAR previousUnits =
    CALCULATE(
        SUM(MYTABLE[Units]),
        FILTER(
            ALLSELECTED(MYTABLE),
            MYTABLE[Year] 
                = CALCULATE (
                    MAX(MYTABLE[Year]),
                    FILTER(ALLSELECTED(MYTABLE), MYTABLE[Year] < CurrentRowDate)
                )
        )
    )
var percentChanged = (currentUnits - previousUnits) / previousUnits 
RETURN IF(ISBLANK(previousUnits), BLANK(),percentChanged)

View solution in original post

6 REPLIES 6
TCavins
Helper V
Helper V

Here's the solution I developed combining various sources I found. It may not be the most condensed but it works:

Units % Changed = 
VAR CurrentRowDate = MAX(MYTABLE[Year])
var currentUnits = CALCULATE(
                                SUM(MYTABLE[Units]),
                                FILTER(
                                    ALLSELECTED(MYTABLE),
                                    MYTABLE[Year] = CurrentRowDate))

VAR previousUnits =
    CALCULATE(
        SUM(MYTABLE[Units]),
        FILTER(
            ALLSELECTED(MYTABLE),
            MYTABLE[Year] 
                = CALCULATE (
                    MAX(MYTABLE[Year]),
                    FILTER(ALLSELECTED(MYTABLE), MYTABLE[Year] < CurrentRowDate)
                )
        )
    )
var percentChanged = (currentUnits - previousUnits) / previousUnits 
RETURN IF(ISBLANK(previousUnits), BLANK(),percentChanged)
FBergamaschi
Solution Sage
Solution Sage

Here

 

FBergamaschi_0-1757352856413.png

 

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

When I do the measure, it's not letting me select 'table'[year]. I'm trying measures as it needs to calculate on the fly based on Year or any other column the user may filter on to get units for that year/filter.

You asked for a column so I created that. If you want a measure

Meas=

VAR CURRENTYEAR = SELECTEDVALUE(TABLE[YEAR])

RETURN

CALCULATE ( SUM (TABLE[QTY] ), TABLE[YEAR] = CURRENTYEAR-1,

REMOVEFILTERS(TABLE[YEAR])

)

 

If this helped, please consider giving kudos and mark as a solution

@mein replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

)

Not working for me. It's blank.

 

The years could be 2020,2021,2022, 2023,2024,2025.   They could be 2020, 2023, 2025 or any other combination that the user has chosen so I don't think I can just say currentYear -1.

@FBergamaschi So my dataset has Year and Units.  I'm putting them into a Power BI table visual  summing the units to get total by year.   Within the visual, I want to get the % change in total units from the previous row. Filters on the page could make it so the years are not consecutive (2020, 2023, and 2025). I'm using a measure as I want the value to be variable based on what's shown in the visual.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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