Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply

Extract values from row function

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

WillBatesHydro_0-1650379072500.png

 

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

WillBatesHydro_1-1650379337975.png

And I get this;

 

WillBatesHydro_2-1650379511430.png

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.

WillBatesHydro_3-1650379563571.png

 

you can drill down into each row and it will display the desired data.

 

WillBatesHydro_4-1650379686972.png

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

 

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

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],

...

 

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

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! 🙂

Anonymous
Not applicable

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

 

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.