Forum Discussion
Get value from C# app to Power BI Embedded
Hi!
I have my Power BI Reports embedded in a C# app. This app sends by JS a parameter when you select from the home page certain value. I want to catch this value into power BI report and use it to do dynamic titles, filters, etc... How can I do that?
Thanks!
Julián
11 Replies
- v-ljerr-msft
Microsoft Employee
Hi Juramirez,
Following is a good answer from this similar thread(check the bold in the code, you can set the value for the filter there). :smileyhappy:
The Power BI Javascript support set filter when embedding. Check this wiki. You can find a more integrated live demo by clicking Custom Filter Pane.
A simple demo I use to test for your reference.
<html> <script src="https://microsoft.github.io/PowerBI-JavaScript/demo/node_modules/jquery/dist/jquery.js"></script> <script src="https://microsoft.github.io/PowerBI-JavaScript/demo/node_modules/powerbi-client/dist/powerbi.js""></script> <script type="text/javascript"> var embedConfiguration = { type: 'report', accessToken: 'token', embedUrl: 'embedURL' }; var report; window.onload = function () { var $reportContainer = $('#reportContainer'); report= powerbi.embed($reportContainer.get(0), embedConfiguration); var Filter1 = { $schema: "http://powerbi.com/product/schema#advanced", target: { table: "Table1", column: "T1id" }, logicalOperator: "OR", conditions: [ { operator: "Contains", value: "id1" } ] } report.on('loaded', event => { report.getFilters() .then(filters => { filters.push(Filter1);
return report.setFilters(filters); }); }); } function reloadreport(){ var $reportContainer = $('#reportContainer'); powerbi.embedNew($reportContainer.get(0), embedConfiguration); }; </script> <div id="reportContainer"></div> </html>Regards
- Juramirez
Resolver I
Thanks v-ljerr-msft for your answer but that's what I've just donde and it works perfectly. What I want now is to get the URL value into power BI and this way that I can execute an Stored Procedure to bring only the data that I want from SQL Server. I mean, for example, in my app I log in with a user that has as idFromURL = "USER1" and this id is right now being passed by url and is filtering all the data of all the users (because the database bring everything) by this id but if I can get this id into the moment that power bi goes to de DB and filter it by an SP (or something that just bring me the data respect that id). I expect something like this:
Sql.Database("server", "database", [Query="EXEC sp_BringDataByUserID @User = 'idFromURL' "])
Hope you can help me ! :D
- gilbertocrespo
Advocate I
I'm waiting for something new here :)