Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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!