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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
jasemilly
Helper II
Helper II

use condition to refer to the previous Row

Hi am I have created a simple table with some test data.  I would like to get the value of the next rows startdate only if the name is the same else I would like it to be blank.

I am getting the following error

jasemilly_0-1625233346772.png

I am able to reference the next row perfectly fine when I don't have the condition  here is my code


let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUNzDXNzIwMlTSUfLKzwOSQCGYmIKBmZWBAUgMIg4TNjQHCcfq4NIP124B0W5MnnZDA4h2EzK1G0G0GxGlPa0oNQXN9SR5Hot+c4h+QzL1w7xPXOhh0W+ML/hiAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [WorkDate = _t, Name = _t, StartDate = _t, Worktype = _t, ShiftEnd = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"WorkDate", type date}, {"Name", type text}, {"StartDate", type text},  {"Worktype", Int64.Type}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type),



//works but Picks up next person start date not what I want
//#"Added Custom" = Table.AddColumn(#"Added Index", "End Task", each  try  #"Added Index"{[Index]}[StartDate] otherwise null)

//errors
#"Added Custom" = Table.AddColumn(#"Added Index", "End Task", each  if  [Name]{[Index]} = [Name]{[Index] - 1}  then #"Added Index"{[Index]}[StartDate] else null  )
in
    #"Added Custom"

 

1 ACCEPTED SOLUTION
Payeras_BI
Solution Sage
Solution Sage

Hi @jasemilly ,

Try with this:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUNzDXNzIwMlTSUfLKzwOSQCGYmIKBmZWBAUgMIg4TNjQHCcfq4NIP124B0W5MnnZDA4h2EzK1G0G0GxGlPa0oNQXN9SR5Hot+c4h+QzL1w7xPXOhh0W+ML/hiAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [WorkDate = _t, Name = _t, StartDate = _t, Worktype = _t, ShiftEnd = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"WorkDate", type date}, {"Name", type text}, {"StartDate", type text},  {"Worktype", Int64.Type}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "End Task", each try if #"Added Index"{[Index]}[Name] = #"Added Index"{[Index] - 1}[Name]  then #"Added Index"{[Index]}[StartDate] else null otherwise null)
in
    #"Added Custom"

Payeras_BI_0-1625235005252.png

 

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain

View solution in original post

1 REPLY 1
Payeras_BI
Solution Sage
Solution Sage

Hi @jasemilly ,

Try with this:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUNzDXNzIwMlTSUfLKzwOSQCGYmIKBmZWBAUgMIg4TNjQHCcfq4NIP124B0W5MnnZDA4h2EzK1G0G0GxGlPa0oNQXN9SR5Hot+c4h+QzL1w7xPXOhh0W+ML/hiAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [WorkDate = _t, Name = _t, StartDate = _t, Worktype = _t, ShiftEnd = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"WorkDate", type date}, {"Name", type text}, {"StartDate", type text},  {"Worktype", Int64.Type}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "End Task", each try if #"Added Index"{[Index]}[Name] = #"Added Index"{[Index] - 1}[Name]  then #"Added Index"{[Index]}[StartDate] else null otherwise null)
in
    #"Added Custom"

Payeras_BI_0-1625235005252.png

 

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Kudoed Authors