Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi All,
Hope you are well,
Hoping you can help me with my issue,
I am looking to extract all Order IDs for each company ID I have via Brightpearls API service.
Below is a list of my company IDs
I am looking to invoke a custom function against each company ID. below is the M code I have to retrieve order numbers for an individual company ID. This function is named 'getorders_bp1_func'
(compid as text)=>
let
Source = () => let
Source = Json.Document(Web.Contents("https://euw1.brightpearlconnect.com/public-api/XXXX/order-service/sales-order-search?customerId=" & compid, [Headers=[#"brightpearl-app-ref"="XXXXX", #"brightpearl-account-token"="XXXX"]])),
response = Source[response],
results = response[results],
#"Converted to Table" = Table.FromList(results, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Extracted Values" = Table.TransformColumns(#"Converted to Table", {"Column1", each Text.Combine(List.Transform(_, Text.From)), type text}),
#"Inserted First Characters" = Table.AddColumn(#"Extracted Values", "First Characters", each Text.Start([Column1], 4), type text),
#"Inserted Text Range" = Table.AddColumn(#"Inserted First Characters", "Text Range", each Text.Middle([Column1], 4, 4), type text)
in
#"Inserted Text Range"
in
Source
So I go back to my list of company IDs, click 'invoke custom function' from the 'add column' tab.
I Select my custom function and use the 'company Ids' column for the 'compid' input as displayed below
And I get this;
As you can see the word function is clickable in each row
When you highlight the function value to preview the words 'function () as any' is displayed.
you can drill down into each row and it will display the desired data.
The problem is, I don't want to drill down, I simply want to expand the column where 'function' is displayed as a value to new rows much like you can do when expanding tables/lists.
Any ideas?
Very much appreciated in davance
Will
Solved! Go to Solution.
try change from this
(compid as text)=>
let
Source = () => let
Source = Json.Document(Web.Contents("https://euw1.brightpearlconnect.com/public-api/XXXX/order-service/sales-order-search?customerId=" & compid, [Headers=[#"brightpearl-app-ref"="XXXXX", #"brightpearl-account-token"="XXXX"]])),
response = Source[response],
to this
let
Source=(compid as text)=>
let
sorgente= Json.Document(Web.Contents("https://euw1.brightpearlconnect.com/public-api/XXXX/order-service/sales-order-search?customerId=" & compid, [Headers=[#"brightpearl-app-ref"="XXXXX", #"brightpearl-account-token"="XXXX"]])),
response = sorgente[response],
...
try change from this
(compid as text)=>
let
Source = () => let
Source = Json.Document(Web.Contents("https://euw1.brightpearlconnect.com/public-api/XXXX/order-service/sales-order-search?customerId=" & compid, [Headers=[#"brightpearl-app-ref"="XXXXX", #"brightpearl-account-token"="XXXX"]])),
response = Source[response],
to this
let
Source=(compid as text)=>
let
sorgente= Json.Document(Web.Contents("https://euw1.brightpearlconnect.com/public-api/XXXX/order-service/sales-order-search?customerId=" & compid, [Headers=[#"brightpearl-app-ref"="XXXXX", #"brightpearl-account-token"="XXXX"]])),
response = sorgente[response],
...
Genius! Don't know how it worked but it definitely fixed my issue!
For my own sanity are you able to explain how you came to offer that adjustment as a potential solution?
Thank you so much! 🙂
I don't know the tool you used that adds a column by calling a user defined function. So I don't know what it produces and with what logic it acts.
In your case, I just tried to reconstruct the correct structure of the definition of a function that FWIK respects the following footprint:
let
functionName=(parameter[s])=>
let
firstStep= do some thing,
...
lastStep = do anhoter thing
in
lastStep
in
functionName
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!