Forum Discussion
Issue with Self join in Dataflow Gen 2
- 1 year ago
Cool. Thanks for the update _Smrithi .
It does seem strange to be getting this error on only 5M rows. Up the the point that you add the indices for self-join, is the query maintaining folding i.e. is 'View Data Source Query' lit up and selectable when you right-click the query step before adding the first index? The more of the query that you can get the source to process (assuming an SQL source) before doing your transformation should help with memory load.
There are other ways to achieve the same result which should avoid the huge amount of table scanning that a merge does. Here's one method that you can try:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUTIw1AciIwMjYyjHDMKJ1UHImyHLW6LKGxroAxFU3thQ39AIKh8LAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, #"Valid From" = _t, #"Valid To" = _t]), Cols = Table.ToColumns(Source), addPrevValidTo = Table.FromColumns(Cols & {{null} & List.RemoveLastN(List.Last(Cols),1)}, Table.ColumnNames(Source) & {"PrevValidTo"}) in addPrevValidToThe example code above transforms this:
...to this:
Pete
Cool. Thanks for the update _Smrithi .
It does seem strange to be getting this error on only 5M rows. Up the the point that you add the indices for self-join, is the query maintaining folding i.e. is 'View Data Source Query' lit up and selectable when you right-click the query step before adding the first index? The more of the query that you can get the source to process (assuming an SQL source) before doing your transformation should help with memory load.
There are other ways to achieve the same result which should avoid the huge amount of table scanning that a merge does. Here's one method that you can try:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUTIw1AciIwMjYyjHDMKJ1UHImyHLW6LKGxroAxFU3thQ39AIKh8LAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, #"Valid From" = _t, #"Valid To" = _t]),
Cols = Table.ToColumns(Source),
addPrevValidTo = Table.FromColumns(Cols & {{null} & List.RemoveLastN(List.Last(Cols),1)}, Table.ColumnNames(Source) & {"PrevValidTo"})
in
addPrevValidTo
The example code above transforms this:
...to this:
Pete
BA_Pete Thanks for providing the solution. Would you let me know if the field, "ID" in the below table have different values?
| Key | Valid From | Valid To |
| 1 | 1/1/2025 | 1/5/2025 |
| 2 | 1/7/2025 | 1/10/2025 |
| 3 | 1/15/2025 | 1/20/2025 |
| 4 | 1/25/2025 | 1/30/2025 |
Thank you,
Smrithi
- v-nmadadi-msft1 year agoCommunity Support
Hi _Smrithi ,
Thanks for reaching out to the Microsoft fabric community forum.
If you're asking whether the query works with a different ID, then yes, I have tested it, and it functions correctly.
Hope the work around provided by BA_Pete was helpful.
If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS.
Thanks and Regards