Forum Discussion
Combining value of rows keeping all columns
- 6 years ago
A 'Group By' solves this. Select multiple columns before clicking 'Group By'
Am I missing something?
- 6 years ago
Hi Anonymous ,
They both are right. I just add an image and relative code.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCg1W0lHySy1XiMwvygYyg/NLSzKAtGticQmQMjQwUIrVIajMFEmVU35xSX4eSHl+EVhNeCpYjRHUKOfEvMSURKBAWGJecn5pWWoRplpjEtSa4FGK7hsjNLW++XklRamJOUhKoaYagoyNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Country = _t, City = _t, #"N/S" = _t, #"W/E" = _t, Sales = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Country", type text}, {"City", type text}, {"N/S", type text}, {"W/E", type text}, {"Sales", Int64.Type}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"Country", "City", "N/S", "W/E"}, {{"Sum", each List.Sum([Sales]), type nullable number}}) in #"Grouped Rows" - 5 years ago
Group By Order Number and Purchase Number
and use aggregations on: Sum of Quantity and Max of Date
Hi all,
I have stumbled upon another problem related to this, I hope somebody has a solution. I did the assumption below based on that all the fields that are the same should be grouped to one row, but I have some rare exceptions where I have one specific column that could be different. It could look like this (after grouping)
| Order number | Date | Purchase number | Quantity |
| 11111 | 01-01-2020 | 010101 | 100 |
| 11111 | 01-01-2020 | 010101 | 50 |
| 22222 | 02-02-2020 | 020202 | 200 |
| 22222 | 15-02-2020 | 020202 | 300 |
| 33333 | 03-03-2020 | 030303 | 40 |
| 33333 | 03-02-2020 | 030303 | 60 |
When I do my grouping the following happens; one order (22222) does not get the summarized quantity to one row because one column (date) is different.
| Order number | Date | Purchase number | Quantity |
| 11111 | 01-01-2020 | 010101 | 150 |
| 22222 | 02-02-2020 | 020202 | 200 |
| 22222 | 15-02-2020 | 020202 | 300 |
| 33333 | 03-03-2020 | 030303 | 100 |
I understand that PowerBI is behaving correctly, but in this case I would simply like PowerBI to summarize the two rows and use the latest date value to look like this:
| Order number | Date | Purchase number | Quantity |
| 11111 | 01-01-2020 | 010101 | 150 |
| 22222 | 15-02-2020 | 020202 | 500 |
| 33333 | 03-03-2020 | 030303 | 100 |
If anybody also have any idea for how I can label this row for later analysis (a separate column saying "Merged date" for example) that would be very beneficial as well, so I later know which rows have been merged even though the date has been different.
I would be very grateful if somebody has any idea for this. Thank you very much in advance.
- HotChilli5 years ago
Community Champion
Group By Order Number and Purchase Number
and use aggregations on: Sum of Quantity and Max of Date
- Anonymous5 years agoNot applicable
This works great, thank you!