Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by watching the DP-600 session on-demand now through April 28th.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
I have two columns, A parent column which gives the name of each parent and a child column that represents the type of child each parent has. I would like to create a new column within the query editor that tells me if a parent has a toddler, an infant or both. For example the new column would show that John has “both”, Tom has “Toddler”, Mike has “infant” and Bob has “Both”
| Parent | Child |
| John | Toddler |
| John | infant |
| John | infant |
| Tom | Toddler |
| Tom | Toddler |
| Tom | Toddler |
| Mike | infant |
| Mike | infant |
| Mike | infant |
| Bob | Toddler |
| Bob | infant |
| Bob | infant |
Solved! Go to Solution.
This should work:
Note: your third "Tom" has a trailing space. Also, you may be aware Power Query string comparisons are case sensitive by default.
let
// Your table
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8srPyFPSUQrJT0nJSS1SitWBC2XmpSXmleAQCcnPRdNFjIhvZnYqqjnEiDjlJ6GZAxHBUAITiAUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Parent = _t, Child = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Parent", type text}, {"Child", type text}}),
// Group rows by "Parent" into Data column
#"Grouped Rows" = Table.Group(#"Changed Type", {"Parent"}, {{"Data", each _, type table [Parent=nullable text, Child=nullable text]}}),
// Determine Child Type by rows in Data column
#"Added Child Type" = Table.AddColumn(#"Grouped Rows", "Child Type", each
if Table.ContainsAll([Data], {[Child = "Toddler"], [Child = "infant"]})
then "both"
else if Table.Contains([Data], [Child = "Toddler"])
then "Toddler"
else if Table.Contains([Data], [Child = "infant"])
then "infant"
else null,
type text),
// Expanded back Data to Child
#"Expanded Data" = Table.ExpandTableColumn(#"Added Child Type", "Data", {"Child"}, {"Child"})
in
#"Expanded Data"
This should work:
Note: your third "Tom" has a trailing space. Also, you may be aware Power Query string comparisons are case sensitive by default.
let
// Your table
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8srPyFPSUQrJT0nJSS1SitWBC2XmpSXmleAQCcnPRdNFjIhvZnYqqjnEiDjlJ6GZAxHBUAITiAUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Parent = _t, Child = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Parent", type text}, {"Child", type text}}),
// Group rows by "Parent" into Data column
#"Grouped Rows" = Table.Group(#"Changed Type", {"Parent"}, {{"Data", each _, type table [Parent=nullable text, Child=nullable text]}}),
// Determine Child Type by rows in Data column
#"Added Child Type" = Table.AddColumn(#"Grouped Rows", "Child Type", each
if Table.ContainsAll([Data], {[Child = "Toddler"], [Child = "infant"]})
then "both"
else if Table.Contains([Data], [Child = "Toddler"])
then "Toddler"
else if Table.Contains([Data], [Child = "infant"])
then "infant"
else null,
type text),
// Expanded back Data to Child
#"Expanded Data" = Table.ExpandTableColumn(#"Added Child Type", "Data", {"Child"}, {"Child"})
in
#"Expanded Data"
1, duplicate the table under edit query
2, find one table to groupby "Parent",
3, Merge the two tables together
4, if or switch true create a new column..
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 45 | |
| 38 | |
| 34 | |
| 21 | |
| 17 |
| User | Count |
|---|---|
| 65 | |
| 63 | |
| 31 | |
| 26 | |
| 25 |