Skip to content

Commit 74d3b47

Browse files
authored
Update ExcelWorksheetsRowOutlines.pq
Lost rows index sort after Join (102-103).
1 parent 378ec2f commit 74d3b47

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

RowsOutline/ExcelWorksheetsRowOutlines.pq

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ in
101101
RowIndTable = Table.AddIndexColumn(#table(type table [RowNumber=Int64.Type], RowIndices), "Index"),
102102
ExpandMissedRows = Table.Join(RowIndTable, {"RowNumber"}, Typed, {"RowN"},JoinKind.LeftOuter),
103103
RemovedOtherColumns1 = Table.SelectColumns(ExpandMissedRows,{"Index", "outlineLevel"}),
104-
Result = if Table.IsEmpty(sheetDataTable) then #table(type table [Index = number, outlineLevel = Int64.Type],{}) else RemovedOtherColumns1
104+
PreSort = Table.Sort(RemovedOtherColumns1, {"Index"}),
105+
Result = if Table.IsEmpty(sheetDataTable) then #table(type table [Index = number, outlineLevel = Int64.Type],{}) else PreSort
105106
in
106107
Result,
107108
/////////////////////////////////////////////////////////////////////////////////////////////
@@ -165,13 +166,15 @@ UnZipped = Table.Buffer(fnUnZip(File.Contents(FullPath))),
165166

166167
// invoke RowsOutline function to get separate index+outlineLevel table
167168
AddOutlineTable = Table.AddColumn(MergedRelationsTarget, "RowsOutline", each fnRowsOutline([#"Attribute:Target"]), type table),
168-
// Clean table
169+
170+
// Clean table
169171
RemovedColumns = Table.RemoveColumns(AddOutlineTable,{"Index", "Attribute:Id", "Attribute:Target", "Attribute:name", "Attribute:sheetId", "Attribute:id"}),
170172

171173
// join [AddOutlineTable] and [Data] by rows index
172-
AddedRowsOutline = Table.AddColumn(RemovedColumns, "DataWithOutline", each Table.RemoveColumns(Table.Join([RowsOutline], {"Index"}, Table.AddIndexColumn([Data],"Index"), {"Index"}),{"Index"}), type table),
174+
AddedRowsOutline = Table.AddColumn(RemovedColumns, "DataWithOutline", each Table.RemoveColumns(Table.Join([RowsOutline], {"Index"}, Table.AddIndexColumn([Data],"Index"), {"Index"}), {"Index"}), type table),
173175

174176
// add outlines to Data or not
175177
Result = if AddOutlinesToData or AddOutlinesToData = null then AddedRowsOutline else RemovedColumns
178+
176179
in
177180
Result

0 commit comments

Comments
 (0)