Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
I have data with Id's and dates.
Each ID can have multiple dates with them.
As an output I want only those rows per ID :
1) If ID subsequent dates falls between 45 days then give 1st date row
2) If susequent date is outside 45 days then give both date rows
Solved! Go to Solution.
Hi @Raj12 ,
Give a try to this:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Xc47DsAgDAPQu2RGShwGykgrtYdA3P8aDYiWz/pkW86Z0kmOFCzKKqpUXDcx89X8ZMdi92WGr4vJLBfHXrO6h70bF3tSz4XRbeaFgc3syP+lvA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Id = _t, Date = _t]),
#"Changed Type1" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
#"Grouped Rows" = Table.Group(#"Changed Type1", {"Id"}, {{"AllRows", each _, type table [Id=nullable text, Date=nullable date]}}),
#"Added Shifted Date" = Table.TransformColumns(
#"Grouped Rows",
{
{"AllRows",each
Table.FromColumns(
Table.ToColumns(_) & {{null} & List.RemoveLastN(_[Date],1)},
Table.ColumnNames(_) & {"Previous Date"}
)
}
}
),
Expanded = Table.Combine(#"Added Shifted Date"[AllRows]),
#"Changed Type" = Table.TransformColumnTypes(Expanded,{{"Previous Date", type date}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Delta", each Duration.Days([Date] - [Previous Date]),Int64.Type),
#"Filtered Rows" = Table.SelectRows(#"Added Custom", each [Delta] > 45 or [Delta] = null)
in
#"Filtered Rows"
Hi @Raj12 ,
Give a try to this:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Xc47DsAgDAPQu2RGShwGykgrtYdA3P8aDYiWz/pkW86Z0kmOFCzKKqpUXDcx89X8ZMdi92WGr4vJLBfHXrO6h70bF3tSz4XRbeaFgc3syP+lvA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Id = _t, Date = _t]),
#"Changed Type1" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
#"Grouped Rows" = Table.Group(#"Changed Type1", {"Id"}, {{"AllRows", each _, type table [Id=nullable text, Date=nullable date]}}),
#"Added Shifted Date" = Table.TransformColumns(
#"Grouped Rows",
{
{"AllRows",each
Table.FromColumns(
Table.ToColumns(_) & {{null} & List.RemoveLastN(_[Date],1)},
Table.ColumnNames(_) & {"Previous Date"}
)
}
}
),
Expanded = Table.Combine(#"Added Shifted Date"[AllRows]),
#"Changed Type" = Table.TransformColumnTypes(Expanded,{{"Previous Date", type date}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Delta", each Duration.Days([Date] - [Previous Date]),Int64.Type),
#"Filtered Rows" = Table.SelectRows(#"Added Custom", each [Delta] > 45 or [Delta] = null)
in
#"Filtered Rows"
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.