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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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