Forum Discussion
#shared Data Loads in Preview Window but Not in Model
Hello,
I recently discovered #Shared as a mean of pulling back all existing queries in the Power BI report.
I am trying to use a text string variable to dynamically reference one of several queries in Power BI. Crucially, it needs to be invokable via a custom function (i.e. the value will vary in one column). Given a parameter is fixed once set, this is not sufficient.
So I have a function that uses a text input variable to indicate the query that should be referred to:
let
#"Table" = (yearQuantity,percentileAmount,metricChoice) as table =>
let
Source = Table.SelectRows(Record.ToTable(#shared), each [Name] = "" & metricChoice & ""){0}[Value]
in
Source
in
#"Table"
AND IT WORKS FINE! (I've cut off the rest of the query ultimately)...
But let's say I invoke this with variables as needed, in the "Data Preview" window it works fine and returns the data I need.
But when I try to "Close and Apply" my changes, I get an error message loading the invoked function:
I also tried loading the #shared table in a query of its own, then refer to that query and manipulating it accordingly. Again this works fine in data preview; it just won't load the data to the model.
I hope my issue is clear as I would love some much-needed help!! Thank you