Forum Discussion
Look up and removing duplicates
Hi, hopefully someone can help me with this, I'm fairly new to excel and can't figure out how to make this work.
What I need is for the result to look like this, getting all the values for codes with any data on the same row but returning the values and removing any duplicates found.Thank you!
Let's say the table is called DemoTbl.
You could use this:
=BYROW(DemoTbl[[AAL]:[LPA]],LAMBDA(each_row,TEXTJOIN(",",1,UNIQUE(each_row,1))))
5 Replies
- SergeiBaklanDiamond Contributor
Another Power Query variant
let Source = Excel.CurrentWorkbook(){[Name="Tabelle1"]}[Content], AddResult = Table.AddColumn( Source, "Result", each Text.Combine( List.Distinct( List.Skip( Record.FieldValues(_) ) ), ", " ), type text ), SelectColumns = Table.SelectColumns(AddResult,{"Code", "Result"}) in SelectColumnsTo play with Office Script
function main(workbook: ExcelScript.Workbook) { const sheet = workbook.getActiveWorksheet() const table = workbook.getTable("Tabelle1") const result = workbook.getTable("Result") const target = sheet.getRange("H15:I15") const data = table.getRangeBetweenHeaderAndTotal() if (!result) { target.setValues(Array.of(["Code", "Result"])) sheet.addTable( target, true).setName("Result") } else { const nRows = result.getRowCount() if (nRows) { result.deleteRowsAt(0, nRows) } } for (let row of data.getValues()) { let cleaned = new Set(row.splice(1).filter(x => x)) let ooutput = [row[0]].concat([...cleaned].join(", ")) result.addRow(-1, ooutput ) } }- SilvCopper Contributor
Thank you but I'm sorry I don't think I understand how to use this yet, I'm fairly new in excel, self taught and mostly just use formulas. :(
- OliverScheurichGold Contributor
An alternative could be Power Query. In the attached file you can add data to the blue dynamic table. Then you can click in any cell of the green table and right-click with the mouse and select refresh to update the green result table. This solution works in legacy Excel such as Excel 2013 and in modern Excel.
- Patrick2788Silver Contributor
Let's say the table is called DemoTbl.
You could use this:
=BYROW(DemoTbl[[AAL]:[LPA]],LAMBDA(each_row,TEXTJOIN(",",1,UNIQUE(each_row,1))))- SilvCopper Contributor
This worked really well for me, thank you so much!