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
MaxW
Advocate II
Advocate II

Best way to filter a large dataset to embedded users

I am using embedded reports in my web app, and need to filter reports based on the web app's logged in user. I currently pass the web app userId to USERNAME() when I embed the report and use row level security. The reports are all SQL queries with a 30 minute refresh cycle.

 

This works for small datasets, but I have 10,000 users, and some datasets for all users are several GB which is too big to refresh regularly and the visual interactions are too slow to use.

 

What is the recommended way to surface the report to the customer? Ideally the report would refresh on click with dynamic SQL by passing the userId to the query but I don't believe this is possible?

 

I had an idea to execute API calls on the report button click to update a dataset parameter and refresh the dataset before generating the embed token, but I have hit an API request limit.

11 REPLIES 11
GilbertQ
Super User
Super User

Hi there

Are your reports using Import mode?

Following on from that if you are using an embedded App, what about passing a filter via the URL? The users will not see the Power BI URL, so they will not be able to alter the filters?




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

Hi, 

I am using import, but don't the URL filters just filter the dataset that is already cached? I cant refresh a multi GB dataset every 30 mins. The report might only be run a few times a day but needs to be current for whoever runs it.

Hi @MaxW 

 

When using the URL Filter it will honour the filter for the report being consumed.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

But it wont re-run the SQL query with the filter as a parameter will it?

If you are using Import mode, then it will run the query on the Imported data




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

Right, but I need to filter the SQL, as my dataset is too big to import or refresh. Can Power BI do this?

Hi there

I am not 100% sure with DirectQuery

When you say your dataset is too big, how big is it when designed as a star schema and put say a month or two's worth of data into a PBIX?




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

If I run my SQL query without specifying a userId the result is hundreds of millions of rows and takes 40 minutes to execute. If I can include 'where userid ={userid} then the query is tiny and executes in less than two seconds. How can I get the report to run the query when the report is requested? 

Hi there

You could either use DirectQuery or Composite Models, as long as you have got the UPN in the column which is the UserID?




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

Hi,
I had tried that but couldn't figure out how to pass the USERNAME() as a parameter to the query? All the references to it use DAX after the SQL has already run.

Hi Max,

 

Please see the section in this article about Adding Parameters to Filter Data.  Basically, you just define your parameter, then modify the query to be like 'and userid = " & yourparam & "'

 

https://www.red-gate.com/simple-talk/sql/bi/power-bi-introduction-working-with-parameters-in-power-b...

 

 

 

 

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.

Top Solution Authors
Top Kudoed Authors