Forum Discussion
Paginated reports / Filtering one dataset by another one
- 4 years ago
Hi DataVitalizer,
In Power BI report builder, try this:
Add a new dataset:Select your PBI dataset as datasource:
Open the query designer:
In query designer, click the circled icon:
In the text field, paste this query, you may need to edit the table/ field names to fit your situation:
// DAX Query DEFINE VAR __DS0Core = SUMMARIZECOLUMNS( 'Table1_Data'[EmployeeID], 'Table2_Managers'[ManagerEmail], 'Table2_Managers'[ManagerID], "SumValues", CALCULATE(SUM('Table1_Data'[Values])) ) VAR __DS0PrimaryWindowed = TOPN( 501, __DS0Core, 'Table1_Data'[EmployeeID], 1, 'Table2_Managers'[ManagerEmail], 1, 'Table2_Managers'[ManagerID], 1 ) EVALUATE __DS0PrimaryWindowed ORDER BY 'Table1_Data'[EmployeeID], 'Table2_Managers'[ManagerEmail], 'Table2_Managers'[ManagerID]Press OK, validate the query and press OK again. You should now be able to use the values in the new dataset to achieve your goal.
This query is what Power BI generates when you visualize the desired results in the desktop dataset. To find the query you can use the performance analyzer. That might help you in the future.
You could also use the CALCULATE function to add whichever data you need to your fact table in the desktop version of your dataset so you aren't reliant on relationships. There's a lot of roads that lead to rome in this situation.Cheers
Hi sevenhills
Sorry for my late reply and thank you for you answer.
Please correct me if I am wrong, what you mean is filtering the second dataset (ds_data) by whatever email is seleclted from the parameter which is connected to ds_ManagerEmail ?
I am imagining steps this way when thinking sql
ds_Email
select EmployeeID, ManagerID, ManagerEmail from Table1
ds_data: which should be visualized
select EmployeeID, Revenue
from Table2 where Table2.EmployeeID IN (
select EmployeeID
from Table1
Where ManagerEmail = the email selected from the 1st table)
amitchandak AlexisOlson Greg_Deckler Fowmy I am mentioning you here hoping to get suggestions from you if possible.
Thank you in advance.
DataVitalizer Are your two tables related to one another in your dataset?
- DataVitalizer4 years ago
Super User
Hi Greg_Deckler
Thank you for your time.
I have a Power BI Dataset based on which I have created two datasets within my paginated report in order to acheive the need, not sure if I must create two datasets!?
Thank you in advance.
- Greg_Deckler4 years ago
Community Champion
DataVitalizer No, not two datasets, one dataset with 2 tables but you need to have a relationship between the tables for one to filter the other.
- DataVitalizer4 years ago
Super User
Hi
Greg_Deckler My data model contains two linked tables, I created it on Power BI desktop then publish it to Power BI Service, I am trying to use that published dataset inside power builder
JGroothedde hope this explains the scenario
Thank you in advance.
- JGroothedde4 years ago
Resolver II
Hi DataVitalizer ,
Unfortunately the relationships that are present in your Power BI Dataset do not work in the report builder. You can use the LOOKUP function or manually copy the queries from the dataset into PBI Report Builder as shown in this video.Cheers.