This powerquery function is current tell me it cannot convert a list to text. What is the problem?
code
let
ReferenceTable = Initial_Extract{[Schema="dbo",Item=[Name__Source_Table]]}[Data],
ColumnName = [Name__Source_Column],
AssessContents = Table.AddColumn(ReferenceTable, "Assess", each (if Text.Length(Table.Column(ReferenceTable, ColumnName)) > 5 then "Exceeds 5 Characters" else "Less than 5 Characters")),
Grouping = Table.Group(AssessContents, {"Assess"}, {{"Count", each Table.RowCount(_), Int64.Type}})
in
Grouping
Assistant
The issue in the provided PowerQuery function is that the Table.Column(ReferenceTable, ColumnName) expression is returning a list of values, and the Text.Length() function is not able to handle a list directly.
To fix this, you can use the List.Transform() function to apply the Text.Length() function to each element of the list, and then use the List.Max() function to get the maximum length of the values in the list.
Here's the updated code:
code
User
You are both wrong as the AssessContents step is working perfectly. It's the Grouping step it's failing to perform.
Assistant
Okay, got it. Let me take another look at the issue with the Grouping step.
The problem here is that the Table.Group() function is expecting a single value for each grouping, but the "Assess" column contains a string value, which cannot be directly used as a grouping key.
To fix this, you can use the Table.DistinctValues() function to get the unique values in the "Assess" column, and then use that to group the data.
Here's the updated code:
code
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
let
ReferenceTable = Initial_Extract{[Schema="dbo",Item=[Name__Source_Table]]}[Data],
ColumnName = [Name__Source_Column],
AssessContents = Table.AddColumn(ReferenceTable, "Assess", each (
let
ColumnValues = Table.Column(ReferenceTable, ColumnName),
MaxLength = List.Max(List.Transform(ColumnValues, Text.Length))
in
if MaxLength > 5 then "Exceeds 5 Characters" else "Less than 5 Characters"
)),
Grouping = Table.Group(AssessContents, {"Assess"}, {{"Count", each Table.RowCount(_), Int64.Type}})
in
Grouping
In this updated code, the Table.Column(ReferenceTable, ColumnName) expression returns a list of values, which is then passed to the List.Transform() function to apply the Text.Length() function to each element. The List.Max() function is then used to get the maximum length of the values in the list, which is used in the if statement to determine the "Assess" value.
This should resolve the issue with the original code, which was unable to convert the list of values to text.
let
ReferenceTable = Initial_Extract{[Schema="dbo",Item=[Name__Source_Table]]}[Data],
ColumnName = [Name__Source_Column],
AssessContents = Table.AddColumn(ReferenceTable, "Assess", each (
let
ColumnValues = Table.Column(ReferenceTable, ColumnName),
MaxLength = List.Max(List.Transform(ColumnValues, Text.Length))
in
if MaxLength > 5 then "Exceeds 5 Characters" else "Less than 5 Characters"
)),
UniqueAssessValues = Table.DistinctValues(AssessContents, "Assess"),
Grouping = Table.Group(AssessContents, {"Assess"}, {{"Count", each Table.RowCount(_), Int64.Type}})
in
Grouping
The main change here is the addition of the UniqueAssessValues step, which uses Table.DistinctValues() to get the unique values in the "Assess" column. This ensures that the Table.Group() function can correctly group the data based on the "Assess" column.
Let me know if this resolves the issue you were experiencing with the Grouping step.
Cite this conversation
“This powerquery function is current tell me it cannot convert a list to text. What is….” Conversation with claude-3-haiku-20240307, from the LMArena Human Preference 100K dataset. The Chat Archive, 2026. https://thechatarchive.com/c/01m8516axxr9hfkfv4fvfnrwet