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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
TerriAki
Frequent Visitor

Add a new row per ID with (last date +1 day)

Hi, 

 

Any help would be appreciated on the following problem please:

 

Trying to add a new row per ID with the date value as the last date plus 1 day.  Expected result is in red font, the actual data has over 4 million rows:

 

T&A Table:

Employee IDDate             Status  Week Ending
128/03/2020RD28/03/2020 00:00
129/03/2020S04/04/2020 00:00
130/03/2020S04/04/2020 00:00
131/03/2020S04/04/2020 00:00
101/04/2020RD04/04/2020 00:00
102/04/2020  
228/03/2020S04/04/2020 00:00
229/03/2020RD04/04/2020 00:00
230/03/2020TW11/04/2020 00:00
231/03/2020TW11/04/2020 00:00
201/04/2020111/04/2020 00:00
202/04/2020RD11/04/2020 00:00
203/04/2020111/04/2020 00:00
204/04/2020  
328/03/2020RD11/04/2020 00:00
329/03/2020AL18/04/2020 00:00
330/03/2020HA18/04/2020 00:00
331/03/2020TW18/04/2020 00:00
301/04/2020RD18/04/2020 00:00
302/04/2020TW18/04/2020 00:00
303/04/2020RD18/04/2020 00:00
304/04/2020125/04/2020 00:00
305/04/2020TW25/04/2020 00:00
306/04/2020125/04/2020 00:00
307/04/2020RD25/04/2020 00:00
308/04/2020TW25/04/2020 00:00
309/04/2020  

 

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @TerriAki ,

 

Paste this into a new blank query using Advanced Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jdJNC4JAEAbgvyJ7FpzZ1bJugkJBpww8iAehJaSyIDv075sOkrs6uuDn7sO7O6NlKbL78/b4aO3tU+GLtO403fKu7t4veii0vnpZe27ai6j8UiCNyTgAFUiQQC/H1BjxALYAf7oZ0JxOCAM6JqQCZ4muErCf6Dc6SaVdExsq7ZLmQ42aTgVdEDmKztSoCmeltOvnqXIJVZNfn6fDViWHH40ZarRql8zScas4Ov4BeDrs1UKqck8NrbbKiJORvT5PV86ha3unPI2X16++", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t]),
    promoteHeads = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    chgTypes = Table.TransformColumnTypes(promoteHeads,{{"Week Ending", type datetime}, {"Date", type date}}),
    groupRows = Table.Group(chgTypes, {"Employee ID"}, {{"data", each _, type table [Employee ID=nullable text, Date=nullable date, Status=nullable text, Week Ending=nullable datetime]}}),
    addNestedRow =
        Table.TransformColumns(
            groupRows,
            {"data", each
            Table.InsertRows(_, 0, 
                {
                    [Employee ID = List.Max(_[Employee ID]), Date = Date.AddDays(List.Max(_[Date]), 1), Status = null, Week Ending = null]
                }
            )}
        ),
    expandDataColumn = Table.ExpandTableColumn(addNestedRow, "data", {"Date", "Status", "Week Ending"}, {"Date", "Status", "Week Ending"})
in
    expandDataColumn

 

This gives me the following output:

BA_Pete_0-1647874429480.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

2 REPLIES 2
TerriAki
Frequent Visitor

This is perfect, thank you for the quick response. 

BA_Pete
Super User
Super User

Hi @TerriAki ,

 

Paste this into a new blank query using Advanced Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jdJNC4JAEAbgvyJ7FpzZ1bJugkJBpww8iAehJaSyIDv075sOkrs6uuDn7sO7O6NlKbL78/b4aO3tU+GLtO403fKu7t4veii0vnpZe27ai6j8UiCNyTgAFUiQQC/H1BjxALYAf7oZ0JxOCAM6JqQCZ4muErCf6Dc6SaVdExsq7ZLmQ42aTgVdEDmKztSoCmeltOvnqXIJVZNfn6fDViWHH40ZarRql8zScas4Ov4BeDrs1UKqck8NrbbKiJORvT5PV86ha3unPI2X16++", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t]),
    promoteHeads = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    chgTypes = Table.TransformColumnTypes(promoteHeads,{{"Week Ending", type datetime}, {"Date", type date}}),
    groupRows = Table.Group(chgTypes, {"Employee ID"}, {{"data", each _, type table [Employee ID=nullable text, Date=nullable date, Status=nullable text, Week Ending=nullable datetime]}}),
    addNestedRow =
        Table.TransformColumns(
            groupRows,
            {"data", each
            Table.InsertRows(_, 0, 
                {
                    [Employee ID = List.Max(_[Employee ID]), Date = Date.AddDays(List.Max(_[Date]), 1), Status = null, Week Ending = null]
                }
            )}
        ),
    expandDataColumn = Table.ExpandTableColumn(addNestedRow, "data", {"Date", "Status", "Week Ending"}, {"Date", "Status", "Week Ending"})
in
    expandDataColumn

 

This gives me the following output:

BA_Pete_0-1647874429480.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.