Forum Discussion
Provide column header from selection
Hi,
I am looking of a way to convert this vacation selection template from "x" selections to column headers but shift columns if more than one selection is made.
Have:
ID | Store | Dept | Name | Dec 31 - Jan 06 | Jan 07 - Jan 13 | Jan 14 - Jan 20 | Jan 21 - Jan 27 | Jan 28 - Feb 03 | Feb 04 - Feb 10 | Feb 11 - Feb 17 | Feb 18 - Feb 24 | Feb 25 - Mar 02 | Mar 03 - Mar 09 | Mar 10 - Mar 16 | Mar 17 - Mar 23 | Mar 24 - Mar 30 | Mar 31 - Apr 06 | Apr 07 - Apr 13 | Apr 14 - Apr 20 | Apr 21 - Apr 27 | Apr 28 - May 04 | May 05 - May 11 | May 12 - May 18 | May 19 - May 25 | May 26 - Jun 01 | Jun 02 - Jun 08 | Jun 09 - Jun 15 | Jun 16 - Jun 22 | Jun 23 -Jun 29 | Jun 30 - Jul 06 | Jul 07 - Jul 13 | Jul 14 - Jul 20 | Jul 21 - Jul 27 | Jul 28 - Aug 03 | Aug 04 - Aug 10 | Aug 11 - Aug 17 | Aug 18 - Aug 24 | Aug 25 - Aug 31 | Sep 01 - Sep 07 | Sep 08 - Sep 14 | Sep 15 - Sep 21 | Sep 22 - Sep 28 | Sept 29 - Oct 05 | Oct 06 - Oct 12 | Oct 13 - Oct 19 | Oct 20 - Oct 26 | Oct 27 - Nov 02 | Nov 03 - Nov 09 | Nov 10 - Nov 16 | Nov 17 - Nov 23 | Nov 24 - Nov 30 | Dec 01 - Dec 07 | Dec 08 - Dec 14 | Dec 15 - Dec 21 | Dec 22-Dec 28 | Dec 29 - Jan 04 |
300930926 | 318 | Store | CR | x | x | |||||||||||||||||||||||||||||||||||||||||||||||||||
300978152 | 318 | Store | KA | x | ||||||||||||||||||||||||||||||||||||||||||||||||||||
300922244 | 318 | Store | AL | x | x | |||||||||||||||||||||||||||||||||||||||||||||||||||
300942085 | 318 | Store | SW | x | x | |||||||||||||||||||||||||||||||||||||||||||||||||||
300880350 | 318 | Store | BJ | x | x | |||||||||||||||||||||||||||||||||||||||||||||||||||
301027720 | 318 | Store | GC | |||||||||||||||||||||||||||||||||||||||||||||||||||||
300409627 | 318 | Store | DG | x | x | |||||||||||||||||||||||||||||||||||||||||||||||||||
300576717 | 318 | Store | JO | x | x | x | ||||||||||||||||||||||||||||||||||||||||||||||||||
300993701 | 318 | Store | FT | x |
I am looking to have it turn out like the below. I have to do this to 1,000+ rows and I am trying to not do it all by hand.
Want:
ID | Store | Dept | Name | Week 1 | Week 2 | Week 3 | Week 4 |
300930926 | 318 | Store | CR | Apr 07 - Apr 13 | Oct 27 - Nov 02 | ||
300978152 | 318 | Store | KA | Aug 04 - Aug 10 | |||
300922244 | 318 | Store | AL | Feb 11 - Feb 17 | Jul 07 - Jul 13 | ||
300942085 | 318 | Store | SW | Jun 16 - Jun 22 | Dec 15 - Dec 21 | ||
300880350 | 318 | Store | BJ | May 05 - May 11 | Jul 07 - Jul 13 | ||
301027720 | 318 | Store | GC | ||||
300409627 | 318 | Store | DG | Aug 11 - Aug 17 | Aug 18 - Aug 24 | ||
300576717 | 318 | Store | JO | Apr 07 - Apr 13 | Aug 04 - Aug 10 | Oct 13 - Oct 19 | |
300993701 | 318 | Store | FT | Dec 08 - Dec 14 |
It can be in a separate workbook or different sheet tab.
BrianJm86 One possible dynamic array formula for MS365 would be:
=LET( table, Master!A1:BE10, data, DROP(table, 1, 4), rowId, SEQUENCE(ROWS(data)), recordCount, BYROW(data, LAMBDA(r, COUNTIF(r, "x"))), maxCount, MAX(recordCount), newRows, maxCount-recordCount, cols, SEQUENCE(, maxCount), unpivot, HSTACK(TOCOL(IFS(recordCount>=cols, rowId), 2), TOCOL(IFS(data="x", DROP(TAKE(table, 1),, 4)), 2)), results, WRAPROWS(DROP(SORT(VSTACK(unpivot, EXPAND(TOCOL(IFS(newRows>=cols, rowId), 2),, 2, ""))),, 1), maxCount), HSTACK(TAKE(table,, 4), VSTACK("Week "&cols, results)) )
It may seem like a lot but is relatively efficient and should perform quite well with 1,000+ rows of data. Adjust the range reference accordingly to select your entire table range (including the header row).
Please see the attached workbook...
- djclementsBronze Contributor
BrianJm86 One possible dynamic array formula for MS365 would be:
=LET( table, Master!A1:BE10, data, DROP(table, 1, 4), rowId, SEQUENCE(ROWS(data)), recordCount, BYROW(data, LAMBDA(r, COUNTIF(r, "x"))), maxCount, MAX(recordCount), newRows, maxCount-recordCount, cols, SEQUENCE(, maxCount), unpivot, HSTACK(TOCOL(IFS(recordCount>=cols, rowId), 2), TOCOL(IFS(data="x", DROP(TAKE(table, 1),, 4)), 2)), results, WRAPROWS(DROP(SORT(VSTACK(unpivot, EXPAND(TOCOL(IFS(newRows>=cols, rowId), 2),, 2, ""))),, 1), maxCount), HSTACK(TAKE(table,, 4), VSTACK("Week "&cols, results)) )
It may seem like a lot but is relatively efficient and should perform quite well with 1,000+ rows of data. Adjust the range reference accordingly to select your entire table range (including the header row).
Please see the attached workbook...
- peiyezhuBronze Contributor
sql:
create temp table aa as
select rowid old_rowid, * from basic_to_one_dim;
cli_one_dim~temp.aa~5;
select ID,Store,Dept,Name,group_concat(属性,'</td><td>') `week1</td><td>week2</td><td>week3` from aaunion group by ID,Store,Dept,Name order by old_rowid; - SandeepMarwalBrass Contributor
It can be done using power query.
refer attached workbook.
copy your complete data in master sheet.
Then in "results" sheet, right click in query output table and choose refresh.