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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Resolver I
Resolver I

Get value from C# app to Power BI Embedded



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?




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). Smiley Happy

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.



 <script src=""></script>  
 <script src="""></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: "",
target: {
table: "Table1",
column: "T1id"
logicalOperator: "OR",
conditions: [
operator: "Contains",
value: "id1"
report.on('loaded', event => {
    .then(filters => {
return report.setFilters(filters); }); }); } function reloadreport(){ var $reportContainer = $('#reportContainer'); powerbi.embedNew($reportContainer.get(0), embedConfiguration); }; </script> <div id="reportContainer"></div> </html>



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 ! 😄

@Juramirez  this link really save my life 🙂

ONE line difference. Just a small adjustment on power bi desktop.


Also, they updated the sample



Thanks @gilbertocrespo


Let me check if it works for me! 



Hi @gilbertocrespo.


How did you get the value from the URL? I mean, i'm passing an ID by URL but i don't know how to get this value in my advanced editor to call an StoredProcedure (SQL Server) with this ID as value for my StoredProcedure. I want something like this: 

Sql.Database("server", "database", [Query="EXEC sp_BringDataByUserID @User = 'idFromURL' "])



Hi @Juramirez


I want the Same in C# Code but with different parameters 'Start Date' and 'End Date'. I have done this on power bi desktop with Manage parameter functionality and it works fine but Now I Want to pass these parameters dynamicaly from C# Code. Can you please update me for the same if you have any idea.


Thanks in Advance.

I guess you are focusing on Stored Procedure too much. Let the PowerBI does this service to you.



On controller Home\HomeController.cs,  before to generate token:


var generateTokenRequestParameters = new GenerateTokenRequest("View", null, identities: new List<EffectiveIdentity> { new EffectiveIdentity(username: "5", datasets: new List<string> { report.DatasetId }, roles: new List<string> { "clientid" }) });


5 is my clientId

clientid is the collumn name I created on each report



On PowerBI Desktop:

Enter the following DAX expression on your report:

[clientid] = VALUE( USERNAME() )

 note: I'm using value() to converts my string into int


This way your data is filtered BEFORE to bring it to PowerBi Service.

Thanks for your reply @gilbertocrespo


With the code that you give me is like filtering a dataset that has all the Clients, am I wrong? I mean, you're importing all database and with this you're allowing to see the data refered to the clientid that is getting in.  This way the dataset size is the same for a huge Client than a small client or not? I want a SP because this way (as I thought) I can bring the data directly (not filtering or by permissions) from my DB only for the client that is getting in and this way the size will be different depending the client size.



Hello my friend @Juramirez,

My current database is small and i don't see any difference.


Filter does that you talking about, because it works after the report is built.

I'm not 100% sure, but RLS don't does it.


@v-ljerr-msft Could you help us solving this question?

Does the dataset size brought by powerBI service is the same if I filter it by using RLS?  I mean, Does the Power BI just hide a content or includes a WHERE clause when building a dataset transported?

Hi @gilbertocrespo


Ok, thanks for your explain. The question that you're doing to @v-ljerr-msft is the one that i need to solve. Any answer for this one?

Thanks in advance.

I'm waiting for something new here 🙂

Helpful resources

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.


Power BI Monthly Update - May 2024

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


Fabric certifications survey

Certification feedback opportunity for the community.