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
Pranali_R
Frequent Visitor

How to reference previous record. Need help on DAX

Hi I am trying to get the % change between consecutive records. 

Logic to determine the previous record is to sort the Pack Size in ascending order and then get the percentage change.

 

Help me to determine the previous record.

JenniferWallace_0-1708357385863.png

@123abc @talespin 

2 ACCEPTED SOLUTIONS
Dangar332
Super User
Super User

HI, @Pranali_R 

try below column

 

Column = 
var a = MAXX(FILTER('Table','Table'[package size]<EARLIER('Table'[package size])),'Table'[package size])
var b = CALCULATE(SUM('Table'[dollar]),FILTER('Table','Table'[package size]=a))
RETURN
IF(b=BLANK(),BLANK(),('Table'[dollar]-b)/b)

 

 

and convert it to percantage using format pane

View solution in original post

123abc
Community Champion
Community Champion

To reference the previous record and calculate the percentage change between consecutive records in DAX (Data Analysis Expressions), you can use the following steps:

  1. First, ensure that your data is properly sorted in ascending order based on the Pack Size.

  2. You can use DAX functions like EARLIER() and LASTNONBLANK() to reference the previous record and calculate the percentage change.

Here's a sample DAX expression to calculate the percentage change:

 

Percentage Change =
VAR CurrentRecord = TableName[ColumnWithPackSize]
VAR PreviousRecord = CALCULATE(
LASTNONBLANK(TableName[ColumnWithPackSize], 1),
FILTER(ALL(TableName), TableName[ColumnWithPackSize] < CurrentRecord)
)
RETURN
IF(
ISBLANK(PreviousRecord),
BLANK(),
(CurrentRecord - PreviousRecord) / PreviousRecord
)

 

Replace TableName with the name of your table, and ColumnWithPackSize with the name of your column containing the pack sizes.

This expression calculates the percentage change between the current record and the previous record based on the sorted pack size. If there is no previous record (i.e., for the first record), it returns blank.

Make sure to adjust the column names and table names according to your data model. This formula should be added as a new calculated column or measure depending on where you want to use it in your Power BI report or DAX query.

 

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

 

In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.

View solution in original post

2 REPLIES 2
123abc
Community Champion
Community Champion

To reference the previous record and calculate the percentage change between consecutive records in DAX (Data Analysis Expressions), you can use the following steps:

  1. First, ensure that your data is properly sorted in ascending order based on the Pack Size.

  2. You can use DAX functions like EARLIER() and LASTNONBLANK() to reference the previous record and calculate the percentage change.

Here's a sample DAX expression to calculate the percentage change:

 

Percentage Change =
VAR CurrentRecord = TableName[ColumnWithPackSize]
VAR PreviousRecord = CALCULATE(
LASTNONBLANK(TableName[ColumnWithPackSize], 1),
FILTER(ALL(TableName), TableName[ColumnWithPackSize] < CurrentRecord)
)
RETURN
IF(
ISBLANK(PreviousRecord),
BLANK(),
(CurrentRecord - PreviousRecord) / PreviousRecord
)

 

Replace TableName with the name of your table, and ColumnWithPackSize with the name of your column containing the pack sizes.

This expression calculates the percentage change between the current record and the previous record based on the sorted pack size. If there is no previous record (i.e., for the first record), it returns blank.

Make sure to adjust the column names and table names according to your data model. This formula should be added as a new calculated column or measure depending on where you want to use it in your Power BI report or DAX query.

 

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

 

In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.

Dangar332
Super User
Super User

HI, @Pranali_R 

try below column

 

Column = 
var a = MAXX(FILTER('Table','Table'[package size]<EARLIER('Table'[package size])),'Table'[package size])
var b = CALCULATE(SUM('Table'[dollar]),FILTER('Table','Table'[package size]=a))
RETURN
IF(b=BLANK(),BLANK(),('Table'[dollar]-b)/b)

 

 

and convert it to percantage using format pane

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.