Forum Discussion
Column to Row
- 2 months ago
Yes, do this in Power Query.
Select the Task column, then Group By.
Group by Task, create a new column as "All Rows" operation.
Add a custom column: Text.Combine([AllRows][Location], ", ")
Remove the AllRows column.If this answer helped, please click 👍 or Accept as Solution.
-Kedar
LinkedIn: https://www.linkedin.com/in/kedar-pande - 2 months ago
Hi,
Yes, this is possible in Power Query using Group By + Text.Combine.
Steps in Power Query
- Open Power Query Editor
- Select the Task column
- Go to Transform → Group By
- Group by Task
- Add a custom aggregation for Location
Use this M code example:
Table.Group(
Source,
{"Task"},
{
{"Location", each Text.Combine([Location], ", "), type text}
}
)
Expected Output
Task
Location
12345trtr
shfh-y0998, gfhdgh-354y
565656kjhjhkh
45-dgfd, fdhdh098-5, hdfhtrh-453
tryer6666
yuryt7865, tjrtyuyjjfyu, hdgf
This will combine all Location values into a single row separated by commas based on the same Task.
You can also do this in DAX using CONCATENATEX(), but Power Query is the better approach if you want a summarized table and improved performance.
Hope this helps!
Thanks!
- 2 months ago
Hi AllanBerces
You're already at the Grouped Rows step. The only thing missing is converting the nested table into a comma-separated list of locations.Replace:
#"Grouped Rows" = Table.Group(#"Renamed Columns", {"TASK"}, {{"Count", each _, type table [TASK=text, LOCATION=nullable text]}})
with:
#"Grouped Rows" =
Table.Group(
#"Renamed Columns",
{"TASK"},
{
{
"LOCATION",
each Text.Combine(
List.Transform([LOCATION], Text.From),
", "
),
type text
}
}
)Then keep:
in
#"Grouped Rows"This will give you one row per TASK and combine all LOCATION values into a single field separated by commas.
Hi,
Yes, this is possible in Power Query using Group By + Text.Combine.
Steps in Power Query
- Open Power Query Editor
- Select the Task column
- Go to Transform → Group By
- Group by Task
- Add a custom aggregation for Location
Use this M code example:
Table.Group(
Source,
{"Task"},
{
{"Location", each Text.Combine([Location], ", "), type text}
}
)
Expected Output
Task | Location |
12345trtr | shfh-y0998, gfhdgh-354y |
565656kjhjhkh | 45-dgfd, fdhdh098-5, hdfhtrh-453 |
tryer6666 | yuryt7865, tjrtyuyjjfyu, hdgf |
This will combine all Location values into a single row separated by commas based on the same Task.
You can also do this in DAX using CONCATENATEX(), but Power Query is the better approach if you want a summarized table and improved performance.
Hope this helps!
Thanks!
Hi SamInogic Kedar_Pande thank you, i got it.