Forum Discussion
power query
- 1 year ago
Hello VAMONIE
It is an interesting case, I made a test which is working, maybe there is an elegant way to achieve that, but I will follow this post to see that
First I would copy your table in Power query and make a group by
Now in your first table
you have to pivot your artikel column
To ge the following table
Then, you have to make a merge between your 2 tables
Your expand the total from the other table and you can delete the amount from your source table
and I should get the results you need
There is maybe a most efficient way, so I would interested to see it 🙂
- 1 year ago
Hi VAMONIE, check this:
Output
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtIzNNAzMjAyVdJRCkgtKs7PU3AEMn0Ob8sDUpZAbGpgoBSrg1OlU35eaTFUqaEBfrWuFSVFiUDaDIiNcSt1ItoBTiQ4wIk0BwQXpCZnJuZAFZuYwhUbEh1c2FTici02tThci64Ud3BhU0msA/AEFzalWIIrFgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Datum = _t, Name = _t, Artikel = _t, Units = _t, Amount = _t]), ChangedType = Table.TransformColumnTypes(Source,{{"Units", type number}, {"Amount", type number}, {"Datum", type date}}, "sk-SK"), GroupedRows = Table.Group(ChangedType, {"Datum", "Name"}, {{"T", each [ a = Table.RemoveColumns(_, {"Amount"}), b = Table.Pivot(a, List.Distinct(a[Artikel]), "Artikel", "Units"), c = Table.AddColumn(b, "Amount", (x)=> List.Sum([Amount]), type number) ][c], type table}}), ComibnedT = Table.Combine(GroupedRows[T]) in ComibnedT - 1 year ago
Hi VAMONIE
Another possibility
let
Source = Your_Source,
Artikel = List.Distinct(Source[Artikel]),
Group = Table.Group(Source, {"Datum", "Name"},
{{"Data", each Table.FromRows({[Units]}, [Artikel])},
{"Amount", each List.Sum([Amount]), type nullable number}}),
Expand = Table.ExpandTableColumn(Group, "Data", Artikel, Artikel)
in
ExpandStéphane
Hi VAMONIE ,
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you.