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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Each, list transformations and type text field access error

Trying to distill my issue as much as possible:

 

I have a number of records, from which I want to create a table with several columns, each column calling a different function with the record as an argument.

 

 

let
    Repos = Table.FromRecords({
    [CustomerName = "Bob"],
    [CustomerName = "Jim"],
    [CustomerName = "Alice"],
    [CustomerName = "Paula"]
}),
     subItems = Table.ToList(Repos),
    objects = List.Transform(subItems, each 
    Table.FromRecords({[Name = [CustomerName], Key = Text.Combine({"Key for ", [CustomerName]}), Data = Text.Combine({"Data for ",[CustomerName]}), ItemKind = "Table", ItemName = "Table", IsLeaf = true]} ))
in
    objects

 

 

 

 

This gives me what initially appears to be right:

image.png

However upon expansion I get

image.png

Expanding Error gives

 

Expression.Error: We cannot apply field access to the type Text.
Details:
    Value=Bob
    Key=CustomerName

 

Any pointers or ideally a documentation with more examples ?

 

Thanks in advance,

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

In the end it was easier to just take the initial table and add columns (Table.AddColumn...) using as columnGenerator an each (something) which called the relevant functions. 

In other words, the following code

let
    Repos = Table.FromRecords({
    [CustomerName = "Bob"],
    [CustomerName = "Jim"],
    [CustomerName = "Alice"],
    [CustomerName = "Paula"]
}),
    ReposWithKey = Table.AddColumn(Repos,"Key", each Text.Combine({"Key for ", [CustomerName]})),
    ReposWithData = Table.AddColumn(ReposWithKey, "Data", each Text.Combine({"Data for ",[CustomerName]})),
    ReposWithItemKind = Table.AddColumn(ReposWithData, "ItemKind", each "Table"),
    ReposWithItemName = Table.AddColumn(ReposWithItemKind, "ItemName", each "Table"),
    ReposWithLeaf = Table.AddColumn(ReposWithItemName, "isLeaf", each "true")
in
    ReposWithLeaf

did the trick

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

In the end it was easier to just take the initial table and add columns (Table.AddColumn...) using as columnGenerator an each (something) which called the relevant functions. 

In other words, the following code

let
    Repos = Table.FromRecords({
    [CustomerName = "Bob"],
    [CustomerName = "Jim"],
    [CustomerName = "Alice"],
    [CustomerName = "Paula"]
}),
    ReposWithKey = Table.AddColumn(Repos,"Key", each Text.Combine({"Key for ", [CustomerName]})),
    ReposWithData = Table.AddColumn(ReposWithKey, "Data", each Text.Combine({"Data for ",[CustomerName]})),
    ReposWithItemKind = Table.AddColumn(ReposWithData, "ItemKind", each "Table"),
    ReposWithItemName = Table.AddColumn(ReposWithItemKind, "ItemName", each "Table"),
    ReposWithLeaf = Table.AddColumn(ReposWithItemName, "isLeaf", each "true")
in
    ReposWithLeaf

did the trick

v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

You may refer to the links:

 

https://community.powerbi.com/t5/Desktop/quot-Expression-Error-We-cannot-apply-field-access-to-the-type/td-p/401637

 

https://community.powerbi.com/t5/Desktop/We-cannot-apply-field-access-to-the-type-List/td-p/851856

 

https://community.powerbi.com/t5/Power-Query/Expression-Error-We-cannot-apply-field-access-to-the-type-Date/td-p/960281

 

Best Regards,

Amy 

 

Community Support Team _ Amy

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

What's your reason not to start with a list?

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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