Join ODBC connection with Excel Table

Skovgaard

Board Regular
Joined
Oct 18, 2013
Messages
204
Office Version
  1. 365
Platform
  1. Windows
Hi Experts,

Without luck I've explored the internet, so I hope one of you are able to help.

My below ODBC connection is huge, with more than 10 mill rows. I was hoping that I could join with an Excel table, in order to cut down loading time.
If I use the merge functionality in Power Query, it will load all 10 mill rows from the ODBC before the merge, and that is time consuming.

PS. I know the drilldown function with one parameter, but that is not suitable as I need more than one, therefore I was thinking join.


ODBC Connection:
SQL:
SELECT FSLEDG.ESVONO
FROM M3.M3FDBPRD.FSLEDG FSLEDG

OR

Power Query:
Odbc.Query("dsn=M3_PROD", "SELECT FSLEDG.ESVONO#(lf)FROM M3.M3FDBPRD.FSLEDG FSLEDG")


Excel Table:
Power Query:
Excel.CurrentWorkbook(){[Name="Table1"]}[Content]


/Skovgaard
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
An ODBC connection can be brought into the Data Model without Power Query from within Manage in the Power Pivot tab (also available in the Data tab).
1670684416756.png

That would bypass any PQ limitation, although I've imported over 10 million rows without any problem (except it taking FOREVER!).
 
Upvote 0
Hi @Skovgaard,

I think in the cross post there is an interesting suggestion to use parameters.
Seems you are not too familiar with that concept, looking at your reaction over there.

The idea is to limit the ODBC Q1 with a list of products of your Excel Table Q2, right?

I understood the offered solution as followed:
- In Q2 you select the product column and turn it into a list. Make sure it has distinct values.
- Create a new parameter, give it a good name (selection?), set the type, use Query as Suggested values, select the query from the list drop down and use a dummy value in Current Value.
- Pass that Parameter into your ODBC, maybe like (this part I do not know, since I never use that type of connection.)
Power Query:
        Odbc.Query("dsn=M3_PROD", "SELECT FSLEDG.ESVONO#(lf)FROM M3.M3FDBPRD.FSLEDG FSLEDG WHERE M3.M3FDBPRD.PRODUCT = Selection")
1670758008754.png


I tried it in Excel as followed:
Book1
ABCDEFGHIJK
1
2
3Product SelectionProductSalesDate
4P01-dx451P01-dx451430,3725/10/2022
5P01-dl784P01-dl784374,6216/11/2022
6P02-DX654P02-XD456420,1310/10/2022
7P02-XD456P03427,775/10/2022
8P03228,0414/10/2022
9P03415,1625/10/2022
10P03206,023/11/2022
11P04261,7226/10/2022
12P01-dx451466,365/10/2022
13P01-dl784152,117/10/2022
14P02-XD456214,133/10/2022
15P05471,7419/11/2022
16P05413,5715/10/2022
17P06454,7510/11/2022
18
Sheet1


Both are loaded in PQ.
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Selections"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Product Selection", type text}}),
    #"Product Selection" = #"Changed Type"[Product Selection]
in
    #"Product Selection"

The parameter is defined as "Products"
Power Query:
"1" meta [IsParameterQuery=true, ExpressionIdentifier=Selections, Type="Text", IsParameterQueryRequired=true]

Here I do the filtering on the given selection.
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="data"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Product", type text}, {"Sales", type number}, {"Date", type datetime}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each Text.Contains([Product], Products))
in
    #"Filtered Rows"

That's the technique explained, you still need to figure it out to make it work with the ODBC connection, as onfortunately I cannot help you with that.
 
Upvote 0
Hi and thanks for your replies.

I found below homepage, which gave me a solution I understood.
It gave me what I needed, even though the loading process can be very long, if there is too many rows and columns in my table.


/Skovgaard
 
Upvote 0
Solution

Forum statistics

Threads
1,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top