Retrieving only specific columns over ODATA when querying Microsoft NAV

Question

Hey,

My question is pretty straightforward, though it's more about Power Query than PowerBI - How can I retrieve only specific columns when connecting to Microsoft NAV via ODATA connection? My query works as it is but it wastes a lot of time first retrieving the whole table and then dropping unneeded columns, with around 95% of the data retrieved being dropped at this stage. In short, I'd like to pass the columns I keep at the step "Removed Other Columns" when I query for the data in the first step.

MyCompany_ODATA = OData.Feed("https://MyNAVsLocation/POWERBI/odata/Company('MyCompany')/", null, [Implementation="2.0"]),

MyCompany_Raw = MyCompany_ODATA[GLRawTable],

"Removed Other Columns" = Table.SelectColumns(MyCompany_Raw ,{"G_L_Account_No", "Posting_Date", "Document_No", "Description", "Amount", "Global_Dimension_1_Code", "Global_Dimension_2_Code", "User_ID", "Gen_Posting_Type", "CompanyId"})

Any ideas? Also where the hell is the preview post button?

Posted Dec 5, 2018, 10:50 AM UTC

110
KeenJelly•

Have you tried using the native connector or the common app connector to see if they are any faster?

​

For odata the syntax is $select=columnname

https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2015/developers-guide/gg309461(v=crm.7)#BKMK_filter

​

This guide is for dynamics but I imagine it works the same way.

For dynamics I haven't been able to get it to work with the version 9.1 API but it works fine with the 8.2 version.

Also it behaves a bit strangely with dynamics, in that it still pulls in all of the columns, but the values are just listed as null. It is significantly faster though, especially if you have lots of columns.

​

edit: mistake in syntax

2
SilverStreakyOP•

Thanks, gotta test this once I get back to office on Monday.

1
highvoltageacdc1•

I used to use ODATA feeds for on-prem NAV reporting - I eventually found it was faster/easier/more flexible to write SQL queries on the database instead.

2
SilverStreakyOP•

Unfortunately the NAV isn't on-prem but online. I'd love to work with SQL instead for the initial queries.

1
Data_cruncherDAX Rockstar•

Power Query is usually smart enough to perform Query Folding given that Table.SelectColumn() is basically the first step in your M script. Sure, it may look like it's pulling all columns but in reality it may not be. To test -

  1. Install Fiddler & load it up.
  2. Hit refresh in Power BI (not the Power Query window).
  3. Find the OData query that Power Query is generating and confirm that it's selecting only the columns you query.

If this is in-fact pulling all columns, post back here and I can suggest next steps.

2
SilverStreakyOP•

Thanks, I need to try this once I get back to office on Monday. The example I pasted is actually simplified a bit - I pull the general ledger data from several different NAV companies (each with a identical query to one I pasted) and just merge the resultant tables into one all in one query. I'm unfamiliar with Query Folding and what enables/prevents it from working as intended.

1
Data_cruncherDAX Rockstar•

What enables/prevents it from working is purely based upon:

  1. Does the data source support the Power Query function? e.g., in OData you can often pass URL parameters for things like "count"; therefore, Power Query may fold Table.RowCount(). OData will not support things like Table.UnpivotOther(), whereas an MS SQL source will.
  2. Did the Power Query developer include it in their code? The Power Query developers, when developing a connector, often need to explicitly add in folding when designing the connector.
2
Rory_the_dog•

Sounds like you need to drop the columns in the source.

1
SilverStreakyOP•

That's precisely what I'm asking here...

1
Rory_the_dog•

I meant from NAV. But idk what it is so it might not be possible. I'm a beginner.

1