Notifications
Announcements
No record found.
My response was crafted with AI assistance, tailored to provide detailed and actionable guidance for your query. Your issue seems to stem from the fact that you're trying to compare rows within the same dataset without properly aligning or iterating through the rows. The Table.SelectRows function cannot directly reference a row relative to the current one unless you process the table in a way that makes the comparison explicit.
Table.SelectRows
Below is a step-by-step solution using Power Query M:
Power Query M
Add an Index Column to Identify Row Order Use Table.AddIndexColumn to add a unique row index for referencing.
Table.AddIndexColumn
Join the Table with Itself (Offset by One) Duplicate the table and shift the index in one of the copies by +1 to align each row with the next.
Perform a Self-Join on Index Use Table.Join to link the original table with the shifted version using the index columns.
Table.Join
Here’s the corrected M code to achieve this:
m Copy code
let // Step 1: Add an Index Column (starting from 0) SourceWithIndex = Table.AddIndexColumn(Source, "Index", 0, 1, Int64.Type), // Step 2: Add another Index Column (shifted by +1) SourceWithNextIndex = Table.AddIndexColumn(Source, "Index", 1, 1, Int64.Type), // Step 3: Perform a Self-Join MergedTable = Table.Join( SourceWithIndex, "Index", SourceWithNextIndex, "Index", JoinKind.LeftOuter ), // Step 4: Extract Relevant Columns (e.g., current row + next row data) FinalTable = Table.SelectColumns(MergedTable, {"Column1", "Column2", "Column1.1", "Column2.1"}) in FinalTable
SourceWithIndex
SourceWithNextIndex
Index
Source
Column1
Column2
null
Outter[Index]
Index = 0
Rename Duplicate Columns: Identify and rename any duplicate columns in your dataset. You can do this by going to the Modeling tab in Power BI and selecting Transform Data to open Power Query Editor. Look for columns with the same name and rename one of them.
Use Aliases: If renaming columns is not an option, you can use aliases in your formula to differentiate between the columns. For example:
Table.SelectRows( Table.AddColumn(YourTable, "Store1", each [Store]), (Row) => Row[Store1] = "desired_value" )
This way, you're explicitly referencing the columns with different names.
Check Data Source: Ensure that your data source does not have duplicate column names. If it does, you may need to modify the source data to remove duplicates.
Other Solutions 1. **Use Merge Queries instead of Join**: Power Query's Merge Queries allows specifying which columns to include in the result. * Go to Home tab > Merge Queries. * Select the common column and choose the columns you want to include. 2. **Drop duplicate columns after joining**: Use the `Table.RemoveColumns` function. ```powerquery = Table.RemoveColumns( JoinedTable, {"Store"} )
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Tom_Gioielli 170 Super User 2025 Season 2
#ManoVerse 61
Gerardo RenterÃa Ga... 52 Most Valuable Professional