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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
FearDerBeard
Frequent Visitor

Merge queries?

Have I concluded correctly that I should use Merge Queries functionality to filter the results of another query? 

 

In my scenario I have a list of transactions that can easily filter by date.  I only want to return the subset of customer records associated to those filtered transactions.  This way I only include the customer attributes who were active in that period.

 

In SQL you might use a join on the two tables then filter on the date or a IN function with a subquery.

 

Transaction Table from source

CustomerIDTransactionDtAmount
12/2/2017100
12/3/201775
12/4/2017450
32/2/2017100
32/4/20175
32/4/201725

 

Customer Table from source

CustomerName
1Tony
2Bob
3Stewart

 

Customer table filtered to model

CustomerName
1Tony
3Stewart

 

I basically don't want to include 1MM customer attribute records when I only need 10K.

 

I'm using merge query left outer, but it is a total dog.

 

Thanks

1 ACCEPTED SOLUTION
FearDerBeard
Frequent Visitor

Ok. Here's the work around I found.  Perhaps ineloquent, but functional. 

 

1. I created a view that performed the join between the transaction table and customer table with everything from the customer and only the transaction date from the transaction table. 

2. This was sourced and navigated to in Power Query where I filtered the transaction date like I did for the initial transaction table.

3. I removed the transaction date column from the grid in Power Query using "Remove Columns".

4. I then removed duplicate rows in Power Query using "Remove Rows".

 

This ran quickly and deliver only the unique customers necessary.  I don't know what caused the problem, but if I had to guess it's likely Oracle and Power BI weren't playing nicely which prevented query folding to occur.

View solution in original post

5 REPLIES 5
FearDerBeard
Frequent Visitor

Ok. Here's the work around I found.  Perhaps ineloquent, but functional. 

 

1. I created a view that performed the join between the transaction table and customer table with everything from the customer and only the transaction date from the transaction table. 

2. This was sourced and navigated to in Power Query where I filtered the transaction date like I did for the initial transaction table.

3. I removed the transaction date column from the grid in Power Query using "Remove Columns".

4. I then removed duplicate rows in Power Query using "Remove Rows".

 

This ran quickly and deliver only the unique customers necessary.  I don't know what caused the problem, but if I had to guess it's likely Oracle and Power BI weren't playing nicely which prevented query folding to occur.

FearDerBeard
Frequent Visitor

I came up with this query, but it keeps pulling back more records than filtered:

 

let
    Source = Oracle.Database("myschema", [HierarchicalNavigation=true]),
    myschema= Source{[Schema="myschema"]}[Data],
    Transaction= myschema{[Name="Transaction"]}[Data],
    Customer1= myschema{[Name="Customer"]}[Data],

    #"Filtered Rows" = Table.SelectRows(Transaction1, each [TransactionDt] = PeriodParameter),

    Merge = Table.NestedJoin(#"Filtered Rows",{"CustomerID"},Customer1,{"CustomerID"},"NewColumn",JoinKind.Inner)
in
    Merge

Ok.  I  changed the inner to leftouter.  It returns all the records correctly, but when I remove/include columns it starts to tank in performance.  Hours.

Hi @FearDerBeard,

 

Well I guess you can first create a refrence of your transaction table->delete the amount column->left outer join with the customer table in power BI -> click on the transaction table column-> and finally select the date filter you need.

 

Let me know if this answers your question.

 

Regards,

Sarita

Hmm.  I tried something like that in SQL by joining the two tables to merge the date to the customer table, but when I apply the filter operation it ends up bringing back the full results of the query rather than just the filtered results desired. Here's the code:

 

 

let
    Source = Oracle.Database("ODSPROD", [Query="SELECT C.*, Y.TransactionDt FROM Customer c  JOIN Transaction Y ON Y.CustomerId = P.CustomerId", HierarchicalNavigation=true]),
    #"Filtered Rows" = Table.SelectRows(Source, each [ACADEMIC_PERIOD] = AcademicPeriod)
in
    #"Filtered Rows"

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors