Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
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:
However upon expansion I get
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,
Solved! Go to Solution.
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
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
Hi @Anonymous ,
You may refer to the links:
https://community.powerbi.com/t5/Desktop/We-cannot-apply-field-access-to-the-type-List/td-p/851856
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.
What's your reason not to start with a list?