Forum Discussion
ChrisC01
Apr 07, 2025Copper Contributor
Merge rows with different dates but no date span
I have some spreadsheets with rows that have the same data in column A, different dates in the date columns, but no date span. I'd like to combine them into 1 row with a large date span. For exampl...
- Apr 10, 2025
=IFNA(REDUCE(HSTACK("ID","Desc","Date1","Date2","Comment"),UNIQUE(A2:A16), LAMBDA(u,v,VSTACK(u,LET(filtered,FILTER(A2:E16,A2:A16=v), IF(ROWS(filtered)=1,HSTACK(COOSECOLS(filtered,1),"",COOSECOLS(filtered,3,4)), IF(AND(ROWS(UNIQUE(DROP(DROP(MAP(COOSECOLS(filtered,3), VSTACK(0,COOSECOLS(filtered,4)),LAMBDA(a,b,a-1=b)),1),-1),FALSE))=1, UNIQUE(DROP(DROP(MAP(COOSECOLS(filtered,3), VSTACK(0,COOSECOLS(filtered,4)),LAMBDA(a,b,a-1=b)),1),-1),FALSE)=TRUE), HSTACK(INDEX(filtered,1,1),"", TAKE(COOSECOLS(filtered,3),1),TAKE(COOSECOLS(filtered,4),-1),""), HSTACK(COOSECOLS(filtered,1),"",COOSECOLS(filtered,3,4)))))))),"")This formula returns the desired output in my sample sheet. The formula is available with Excel for the web and Office 365.
ChrisC01
Apr 10, 2025Copper Contributor
This is incredible. Thank you so much. I did find a typo in the formula - COOSECOLS should be CHOOSECOLS, but it works perfectly with that fix.