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
RPAI2812
Helper I
Helper I

Merge information row by row

Hi!

 

I would like to transform a dataset I have. Currently I have these 4 columns and normally (but not always) the values column "Day" and "Night" repeat once. Then I have the initial dates that could be kind of "merged". I mean, Initial date from week 1 and end date from week 2.

 

Is there a way I can create a new column "end date customized" which it shows the end date of the 2nd week if the "Day" value is the same between two consecutive rows?

 

RPAI2812_0-1656963744493.png

 

1 ACCEPTED SOLUTION
Payeras_BI
Solution Sage
Solution Sage

Hi @RPAI2812 ,

If understood well, you could group by Day (GroupKind.Local) and get the max of End date.

See below:

Payeras_BI_0-1657006316766.pngPayeras_BI_1-1657006348812.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjLTNzTUNzIwMlbSUTIw0jc0gnH8cxIVwvSAjIDUotzEvNS8EgVDpVidaCUDYyRVBpbEaDE0QFJlaIasJSVFwRtVixFEizmSKiNjglpiAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Initial date" = _t, #"End date" = _t, Day = _t, Night = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Initial date", type date}, {"End date", type date}, {"Day", type text}, {"Night", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Day"}, {{"All", each _, type table [Initial date=nullable date, End date=nullable date, Day=nullable text, Night=nullable text]}, {"End date customized", each List.Max([End date]), type nullable date}},GroupKind.Local),
    #"Expanded All" = Table.ExpandTableColumn(#"Grouped Rows", "All", {"Initial date", "End date", "Night"}, {"Initial date", "End date", "Night"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Expanded All",{"Initial date", "End date", "Day", "Night", "End date customized"})
in
    #"Reordered Columns"

 

 

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 @RPAI2812 ,

If understood well, you could group by Day (GroupKind.Local) and get the max of End date.

See below:

Payeras_BI_0-1657006316766.pngPayeras_BI_1-1657006348812.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjLTNzTUNzIwMlbSUTIw0jc0gnH8cxIVwvSAjIDUotzEvNS8EgVDpVidaCUDYyRVBpbEaDE0QFJlaIasJSVFwRtVixFEizmSKiNjglpiAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Initial date" = _t, #"End date" = _t, Day = _t, Night = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Initial date", type date}, {"End date", type date}, {"Day", type text}, {"Night", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Day"}, {{"All", each _, type table [Initial date=nullable date, End date=nullable date, Day=nullable text, Night=nullable text]}, {"End date customized", each List.Max([End date]), type nullable date}},GroupKind.Local),
    #"Expanded All" = Table.ExpandTableColumn(#"Grouped Rows", "All", {"Initial date", "End date", "Night"}, {"Initial date", "End date", "Night"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Expanded All",{"Initial date", "End date", "Day", "Night", "End date customized"})
in
    #"Reordered Columns"

 

 

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
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!

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.