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
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.
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
- DataVitalizer4 years ago
Super User
Hi JGroothedde
Thank you for your time.
I followed the steps you shared and I got the data to visualize.
When I add a new parameter in the dataset settings and try to render report I get a dependency issue.
Thank you in advance.
- JGroothedde4 years ago
Resolver II
- DataVitalizer4 years ago
Super User
Hi JGroothedde
I created a paramater based on the resulted dataset ManagerEmail then I added a condition in the filter tab of the dataset where DataSet1.ManagerMail = @ManagerEmailWhen rendreding I get this message
The report parameter 'ManagerEmail' has a DefaultValue or a ValidValue that depends on the report parameter "ManagerEmail". Forward dependencies are not valid.
Thank you in advance.
- JGroothedde4 years ago
Resolver II
Hi DataVitalizer ,
Can you try deleting the condition in the filter tab of the dataset and try this:
1) Right-click on parameter and select 'parameter properties'2) Select 'Available values' in the list on the left
3) Check the 3rd option (Get values from a query)
4) Set the following fields like this:
Does that solve the issue for you?