Don't miss your chance to take exam DP-600 or DP-700 on us!
Request nowLearn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
I have a custom function that takes a table and expands it using the Table.ExpandTableColumn() function.
If I invoke it manually it successully runs, but if I call it from within a query I get this response and error.
The error reads
The first thing I did was find out which "Data" it was referring to and it pointed to the "Data" in the Table.ExpandTable Columns function inside the query. I've tried everything I can think of to get to work including feeding it my previous table name which gave me a table, but not the data results needed. Ex: fx1ATTRhdr(#"Removed Top Rows")).
Any ideas where things may be going wrong or what it's looking for once it's inside the function? Any help or directions's appreciated.
Try changing your function to
(MTData as table) =>
let
BaseHeaders = Table.ExpandTableColumn(#"Removed Top Rows", "fx1ATTThdr", each fx1ATTRhdr([Data]))
in
BaseHeaders
--Nate
Hi Nate , thanks for responding with a solution. I may be implementing your solution incorrectly, but it's giving me an error. It doesn't recognize #"Removed Top Rows", which would be located in the query calling this function.
I cut off my full BaseHeaders thats located inside the function. But it looks like this and using MTdata parameter defined as the table I'm trying to bring in from the query, process and return the result.
BaseHeaders = Table.ExpandTableColumn(MTdata, "Data", {"Column1", "Column2", "Column3", "Column4", "Column5", "Column6", "Column7", "Column8", "Column9", "Column10", "Column11", "Column12", "Column13", "Column14", "Column15", "Column16", "Column17", "Column18", "Column19", "Column20", "Column21", "Column22", "Column23", "Column24", "Column25", "Column26", "Column27", "Column28", "Column29", "Column30", "Column31", "Date"}, {"Column1", "Column2", "Column3", "Column4", "Column5", "Column6", "Column7", "Column8", "Column9", "Column10", "Column11", "Column12", "Column13", "Column14", "Column15", "Column16", "Column17", "Column18", "Column19", "Column20", "Column21", "Column22", "Column23", "Column24", "Column25", "Column26", "Column27", "Column28", "Column29", "Column30", "Column31", "Date"})
Just to note again, the function functions if I manually run it. It's calling it from a query with the Add Column (Invoke Custom function) that it fails to find "Data". I confirmed its getting into the function but failing on that ExpandTableColumn line, on both of our lines.
I may very well be misreading your solution, but since I'm making this change from within the Custom Function, that would mean this line would be calling on itself (each fxATTRhdr([Data]). Maybe that's possible. I'm still learning and getting my eyes opened to the things that are possible with M Code. I'm just trying to trace and understand the logic.
Any additional clarity would be appreciated Nate. THanks again!
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Check out the February 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 9 | |
| 9 | |
| 8 | |
| 7 | |
| 6 |