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

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.

Reply
Husain
Advocate I
Advocate I

Function.ScalarVector in M / Power Query

Hi Gurus

 

@ImkeF @MarcelBeug 

 

I am trying to pull information for certain US stocks from finance.yahoo.com

 

The web address follows a similar pattern for all stock symbols

 

https://finance.yahoo.com/quote/AAPL/key-statistics?p=AAPL

So I wrote a custom function


(Ticker) => try Web.Page(
Web.Contents("https://finance.yahoo.com/quote/" & Ticker & "/key-statistics?p=" & Ticker,[Timeout=#duration(0,0,0,10)])) otherwise null

 and invoked it over the symbols i have.
It works but is very slow when i use 500 + symbols

I read about function.scalarvector in Chris Webb's blog

 

https://blog.crossjoin.co.uk/2018/11/16/function-scalarvector-optimise-power-query-m-functions/

 

Please could you help me optimize the web queries using this or any other way

 

I tried with following. It works but does not optimize the query

 

Function.ScalarVector(
    type function(Tickersymbol as text) as text,
    (InputTable) =>
        let
            BufferTable = Table.Buffer(InputTable),
            InputList = BufferTable[Tickersymbol],
            CallFunction = GetStatistics(InputList)            
        in
            CallFunction
)

Please the see the file for more clarity

https://drive.google.com/file/d/12C280ItzuSf7D6cYr-Nl8wj9NzuCeAxu/view?usp=sharing

 

 

 

1 REPLY 1
ImkeF
Community Champion
Community Champion

Function looks as it should, so it might not be supported by the yahoo then.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.