query. Expression.Error: We cannot convert the value to type Function

Jaslin Raj 1 Reputation point
2021-02-11T18:39:20.057+00:00

I am trying to fetch data from Yahoo finance, the code is below

(Symbol as text) as table =>
let
Source = Json.Document(Web.Contents("https://query1.finance.yahoo.com/v8/finance/chart/"&Symbol()&"?region=US&lang=en-US&includePrePost=false&interval=1d&useYfid=true&range=1d&corsDomain=finance.yahoo.com&.tsrc=finance")),
chart = Source[chart],
result = chart[result],
result1 = result{0},
indicators = result1[indicators],
quote = indicators[quote],
quote1 = quote{0},
#"Converted to Table" = Record.ToTable(quote1),
#"Expanded Value" = Table.ExpandListColumn(#"Converted to Table", "Value"),
#"Transposed Table" = Table.Transpose(#"Expanded Value"),
#"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{<!-- -->{"high", type number}, {"open", type number}, {"low", type number}, {"close", type number}, {"volume", Int64.Type}}),
#"Reordered Columns" = Table.ReorderColumns(#"Changed Type",{"open", "high", "low", "close", "volume"})

in
#"Reordered Columns"

I have converted it into a function, when I enter a value for a function, it throws the following error.

An error occurred in the ‘’ query. Expression.Error: We cannot convert the value "SBIN.NS" to type Function.
Details:
Value=SBIN.NS
Type=[Type]

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
36,305 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ehren (MSFT) 1,781 Reputation points Microsoft Employee
    2021-02-11T20:48:33.603+00:00

    Instead of:
    ...& Symbol**()** &...

    You should be doing:
    ...& Symbol &...

    1 person found this answer helpful.
    0 comments No comments