Forum Discussion
umasankar30
1 year agoNew Member
Adding new index
i want to add index in power query with folder data, after creating index, i want to add new index for newly added folder in same folder path without affecting the old index. let Source = Folder...
- 1 year ago
updated code:
let Source = Folder.Files("C:\\Umasankar\\Tenders\\B&R"), // Extract folder metadata #"Inserted Tender Name" = Table.AddColumn(Source, "Tender Name", each Text.BetweenDelimiters([Folder Path], "\", "\", 6, 0), type text), #"Inserted Company" = Table.AddColumn(#"Inserted Tender Name", "Company", each Text.BetweenDelimiters([Folder Path], "\", "\", 5, 0), type text), // Remove unnecessary columns and clean up #"Removed Columns" = Table.RemoveColumns(#"Inserted Company",{"Content", "Date accessed", "Attributes", "Folder Path"}), #"Removed Duplicates" = Table.Distinct(#"Removed Columns", {"Tender Name"}), // Load old indexed data (replace with actual query or table reference) OldData = YourOldIndexedTable, // Find new rows (anti-join) NewRows = Table.NestedJoin(#"Removed Duplicates", "Tender Name", OldData, "Tender Name", "OldData", JoinKind.LeftAnti), // Add new index to new rows #"Added New Index" = Table.AddIndexColumn(NewRows, "Index", Table.RowCount(OldData) + 1, 1, Int64.Type), // Combine old and new data CombinedData = Table.Combine({OldData, #"Added New Index"}), // Final cleanup (optional) #"Sorted Data" = Table.Sort(CombinedData, {{"Index", Order.Ascending}}) in #"Sorted Data"Key Notes:
- Replace YourOldIndexedTable with your query or table reference that holds the old indexed data.
- The JoinKind.LeftAnti ensures only new rows are indexed.
- The Index for new rows starts from the last index of the old data (Table.RowCount(OldData) + 1).
for further reference please visit https://support.microsoft.com/en-us/office/add-an-index-column-power-query-dc582eaf-e757-4b39-98e6-bb59ae44aa82
sanalytics
1 year agoSuper User
umasankar30
Do not understand your questions properly. Can you please post your input along with your desired output. So that we can help in this regard.
Regards
sanalytics