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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
rpiboy_1
Resolver I
Resolver I

Manipulating Nested Table with Function

Hi all,

 

Attempting to distill a larger problem into smaller bits.

 

Lets say I have a table that looks like this:

IndexDataTypeColumnOfTables
1TypeA<Table>
2TypeB<Table>
3TypeA<Table>
4TypeC<Table>

 

I have a function "FnTransformTable" that is intended to transform each table embedded in the column [ColumnOfTables]. The function accepts two arguements,

 

Tbl as table - the table to be transformed

Filter as text - value used as part of the transformation process

 

Now, I should be able to use Table.AddColumn, to add a new column [ColumnofTransformedTables] which contains the result of transforming each Table in [ColumnOfTables].

 

Result would look like this:

IndexDataTypeColumnOfTablesTransformedTables
1TypeA<Table><newTable>
2TypeB<Table><newTable>
3TypeA<Table><newTable>
4TypeC<Table><newTable>

 

However, when I try that basic expression, I get an error:

 

 

let
    Source = #"SomeQuery",
    #"Invoked Custom Function" = Table.AddColumn(Source, "FnIterator", each FnIterator([DetailedData], [Data Type Parameter]))

in
    #"Invoked Custom Function"

 

 

The error is: "Expression.Error: The field 'DetailedData' of the record wasn't found." Then provides a list of columns and field values from the embedded table for a single row. This suggest to me that is not properly 'getting' the embedded table.

1 ACCEPTED SOLUTION
rpiboy_1
Resolver I
Resolver I

So I finally solved my issue. After further reviewing (i.e. watching YouTube videos) that covered 'each' and '_' in more detail, to ensure I understood how that all worked, I discovered I was doing everything correctly. The problem was I didn't realize/forgot that in my function I had a drill down on the Field with the table, so in effect I was attempting to drill down twice, which explains the error. I disovered my mistake quite by accident after I was toying further with the code and making duplicates.

As they say, if you're trouble-shooting yourself, you're just workin'. 🙂

View solution in original post

2 REPLIES 2
rpiboy_1
Resolver I
Resolver I

So I finally solved my issue. After further reviewing (i.e. watching YouTube videos) that covered 'each' and '_' in more detail, to ensure I understood how that all worked, I discovered I was doing everything correctly. The problem was I didn't realize/forgot that in my function I had a drill down on the Field with the table, so in effect I was attempting to drill down twice, which explains the error. I disovered my mistake quite by accident after I was toying further with the code and making duplicates.

As they say, if you're trouble-shooting yourself, you're just workin'. 🙂

ppm1
Solution Sage
Solution Sage

In your example data, you should use [ColumnOfTables] as the table reference in your function. That is the field that hold the table on that row. Also, why is a custom function needed vs. a simple custom columne with an expression like

 

let

filtervalue = [DataType]

in

Table.SelectRows([ColumnOfTables], each [ColumnToFilter] = filtervalue)

 

What transformations is your function doing?

 

Pat

 

 

Pat

 

Microsoft Employee

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Kudoed Authors