Forum Discussion
Need Help - Filter tables using OR criteria from two table
- Anonymous4 years ago
Hi PradeepDive ,
You can use LOOKVALUE function. However, if there is a relationship between tables, it's more efficient to use the RELATED function.
Sample data.
Table 1
Table 2
Table 3
1.If there're no relationships.
You can create a calculated table as follows.
Table = SUMMARIZE ( FILTER ( ADDCOLUMNS ( 'Table 1', "c1", LOOKUPVALUE ( 'Table 2'[Project ID], 'Table 2'[Project ID], 'Table 1'[Project ID] ), "c2", LOOKUPVALUE ( 'Table 3'[Resource ID], 'Table 3'[Resource ID], 'Table 1'[Resource ID] ) ), [c1] = [Project ID] && [c2] = [Resource ID] ), [Hrs], [Project ID], [Resource ID] )If there're relationships.
You can create a calculated table as follows..
Table 4 = SUMMARIZE ( FILTER ( ADDCOLUMNS ( 'Table 1', "c1", RELATED ( 'Table 2'[Project ID] ), "c2", RELATED ( 'Table 3'[Resource ID] ) ), [c1] = [Project ID] && [c2] = [Resource ID] ), [Hrs], [Project ID], [Resource ID] )Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi PradeepDive ,
You can use LOOKVALUE function. However, if there is a relationship between tables, it's more efficient to use the RELATED function.
Sample data.
Table 1
Table 2
Table 3
1.If there're no relationships.
You can create a calculated table as follows.
Table =
SUMMARIZE (
FILTER (
ADDCOLUMNS (
'Table 1',
"c1",
LOOKUPVALUE (
'Table 2'[Project ID],
'Table 2'[Project ID], 'Table 1'[Project ID]
),
"c2",
LOOKUPVALUE (
'Table 3'[Resource ID],
'Table 3'[Resource ID], 'Table 1'[Resource ID]
)
),
[c1] = [Project ID]
&& [c2] = [Resource ID]
),
[Hrs],
[Project ID],
[Resource ID]
)
If there're relationships.
You can create a calculated table as follows..
Table 4 =
SUMMARIZE (
FILTER (
ADDCOLUMNS (
'Table 1',
"c1", RELATED ( 'Table 2'[Project ID] ),
"c2", RELATED ( 'Table 3'[Resource ID] )
),
[c1] = [Project ID]
&& [c2] = [Resource ID]
),
[Hrs],
[Project ID],
[Resource ID]
)
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank Stephen Tao for the detailed explaination.
My mistake, I did not explain in my question.
There is no relationship between tables, I am trying to achieve the above result in Power query which I will later use to create a dataflow.
2nd is my Table 1 is huge with 1.5M rows of data. I am not sure how efficiently the Dax summarize will work in terms of performance and speed.
Any suggestions
- Anonymous4 years agoNot applicable
Hi PradeepDive ,
Here's the solution in Power Query.
1.Merge queries from two tables.
You’ll get this.
2.Expand columns you need.
3.Add a custom column.
= if [Project ID]=[Table 2.Project ID] and [Resource ID]=[Table 3.Resource ID] then 1 else 04.Filter the rows which value is 1.
5.You can remove the unneeded columns.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- PradeepDive4 years agoHelper II
Thanks Stephen,
I am already using the same approach currently, but as my tables are huge it takes lots of time for merging. I was looking for something which can use to get the output in less and if possible in single line (but not necessary)
Appreciate your time to answer my query though.