И кстати если зайти по ссылке от Максима и изучить именно 4-й способ (это где использование команды
Record.FromList) можно играться и с 3 и 4 и т.д. повторяющимся группами столбцов. Например может повторяться (2) Дата - Количество, а может (3) Дата – Сумма - ДатаСерт, или (4) Дата – Сумма - ДатаСерт - СуммаРезерв и т.д.
Шаги в статье такие:
1. Promote headers
2. Unpivot al columns except common columns. Now our repeating columns becomes repeating groups of rows.
3. Add “Index” column
4. Transform “Index” column with use of
Number.IntegerDivide function. This can be done manually or with UI: Select “Index” column, go to
Transform – From Number – Standard – Divide (Integer). Our goal is to get whole number of “Index”/2 (as we have two repeating columns).
Если повторяется 3 названия то “Index”/3, если 4 - “Index”/4 и т.д.
5. Now each pair of row has the same corresponding number.
6. And here is some magic: now we’ll group rows by this modified “Index”, but as an aggregate function we’ll use non-standard
Records.FromList function. It is not in list of functions available in dialog window, so it should be entered manually or by editing of other aggregate function code:
2 столбца:
Код |
---|
#"Grouped Rows" = Table.Group(#"Integer-Divided Column", {"Имя", "Заказ", "Index"}, {{"Значения", each Record.FromList([Value], {"Дата","Сумма"}), type record}}),
|
3 столбца:
Код |
---|
#"Grouped Rows" = Table.Group(#"Integer-Divided Column", {"Имя", "Заказ", "Index"}, {{"Значения", each Record.FromList([Value], {"Дата","Сумма","ДатаСерт"}), type record}}),
|
4 столбца:
Код |
---|
#"Grouped Rows" = Table.Group(#"Integer-Divided Column", {"Имя", "Заказ", "Index"}, {{"Значения", each Record.FromList([Value], {"Дата","Сумма","ДатаСерт","СуммаРезерв"}), type record}}),
|
Т.е. просто дописываются названия новых повторяющихся столбцов.
7. Now we can remove “Index” and expand “Values” column by clicking on double arrow right to column name, and we got the table we need!
8. Make sure all data has correct type assigned, close & load.
Прикрепил файл с примерами.