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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
gsksarepta
Helper II
Helper II

Get the differential value of column from previous row as new column

Hi, 

Can I know how to generate a new column with differential increase/decrease of a column compared to its previous row/value? Below is an example in Excel, I want to generate blue column based the Column "Lots" in PowerQuery. Thank you in advance. 

gsksarepta_0-1671246640081.png

 

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @gsksarepta 

 

try to add a column with this:

LotsDiff =
VAR _week= [Week]
VAR _lots =
MINX(
    FILTER(
        TableName,
        TableName[Week] = _week-1
    ),
    TableName[Lots]
)
RETURN
IF( _lots<>0, [Lots] - _lots)
 
i tried and it worked like this:
FreemanZ_1-1671248127773.png

 

View solution in original post

2 REPLIES 2
FreemanZ
Super User
Super User

hi @gsksarepta 

 

try to add a column with this:

LotsDiff =
VAR _week= [Week]
VAR _lots =
MINX(
    FILTER(
        TableName,
        TableName[Week] = _week-1
    ),
    TableName[Lots]
)
RETURN
IF( _lots<>0, [Lots] - _lots)
 
i tried and it worked like this:
FreemanZ_1-1671248127773.png

 

Thank you @FreemanZ  it worked perfectly. I just adjusted IF formula to avoid the negative values in column. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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