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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Super User
Super User

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.