Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
papi0506
Frequent Visitor

Extract records into existing rows or combine them afterwards.

Hello, 

I seeking advice on how to combine or consilidate similar columns from records.

 

For example a queury will have columns "name", "id", "level", "Children"

the column "Children" will be a list of records with same named columns, so once extracted it duplicates the exisiting rows and creates new columns for the added rows "name.1", "id.1", "level.1", "Children.1"

Is there a way so that the extracted values will go to the existing columns and just create new rows for the new data? 

Example- 

list:

papi0506_0-1712849425797.png

 

Expanded List:

papi0506_1-1712849468803.png


Expanded Record:

papi0506_2-1712849509077.png

 


What I'm trying to accomplish is for the expaned records to combine instead of creating new columns. Any help is appreciated and thank you in advance. 

papi0506_3-1712849699785.png

 

3 REPLIES 3
wdx223_Daniel
Super User
Super User

you can try this recurrsive function

=let fx=(tbl)=>let a=Table.RemoveColumns(tbl,"Children",MissingField.Ignore),b=List.RemoveNulls(tbl[Children]? ??{}) in if b={} then a else a&@fx(Table.FromRecords(List.Combine(b))) in fx(YourTableName)

@wdx223_Daniel 
Thank you for your suggestion but I apologize as I'm not sure how to fit that into the m code exactly. This screenshot is the error and code. How exactly do I fit this function to this? 

papi0506_1-1713383475441.png

 

papi0506_2-1713383538595.png

 

 

try to delete these two step

wdx223_Daniel_0-1713397691707.png

and replace the step of "test" with this

test=let fx=(tbl)=>let a=Table.RemoveColumns(tbl,"Children",MissingField.Ignore),b=List.RemoveNulls(tbl[Children]? ??{}) in if b={} then a else a&@fx(Table.FromRecords(List.Combine(b))) in fx(#"Expanded Info")

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors