Share via

Power Query vs. FILTER function

Anonymous
2020-02-08T18:52:12+00:00

Split from this thread.

Thanks for your help

can you take a look at this file (link to my OneDrive file)

I have used power query and filter to query and filter 2 identical lists to produce results based on certain cities...

they both produce the same results but my feeling is power query is a bit better as you can filter in detail e.g. filter based on many criteria but doing the same with =filter , while doable, makes for a complicated formula...for example, if I want to produce a sheet of only Atlanta, Auditing, Commercial records.

heres the link

PQ vs Filter - which one is better.xlsx

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Lz365 38,191 Reputation points Volunteer Moderator
2020-02-10T16:42:11+00:00

Craig,

Sample avail. here. You'll see I stored the drop-down values in a Table and created a Connection only to that Table. So the why is the following: if the search the Net on how to pass a value from an Excel workbook to a query, you'll find different ways to do this, and all are valid ones. They usually suggest doing this in 2 steps:

  1. Define a name range at the workbook level - that you be one your drop-down to "capture" its value
  2. In the query do something like (that's one way, as I said before there are others):

myParam = Table.FirstValue(Excel.CurrentWorkbook(){[Name="myDefinedName"]}[Content])

No problem this works

Now, if you have more that one value to pass to a query, storing those values in a Table has at least 3  benefits:

  1. Faster than creating n Defined names + it's a structured approach + if you hide the sheet containing that Table you reduce the risks that someone deletes your Defined names
  2. Easier to update your query if you later need to get additional values from your workbook for your queries
  3. Most important one is efficiency as you read your Table (and if you read it more than one time you can even Buffer it as it's small one), instead of making n calls like Table.FirstValue... mentioned above

Hope this all makes sense

No idea what your level of expertise is re. Power Query. So suggestion is you look at the code of query QueryResult and let me know if you have questions. You will see that I made 1 parameter optional (ClientType)

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

Answer accepted by question author

Lz365 38,191 Reputation points Volunteer Moderator
2020-02-09T06:19:57+00:00

Hi Craig

Given you're open to a non real-time solution (query must be refreshed. It can auto refresh every n minutes) if it was me I would opt for the query option. Main reason being that it returns a Table, and with that table you easily filter, sort…

You can do the same with FILTER but if you want to SORT the output you'll have to change the formula. Also, Conditional Formatting can be applied to a Table, not really on the output of a FILTER as the range the CF rules apply to isn't dynamically adjusted

That being said this all depends on what view(s) you need for your business and how often you need to change the criteria to generate these views

One thing I don't understand though. In your previous request you talked about drop-down lists. Except if I missed something I haven't seen any in the workbook you uploaded. Have you given up on that part or is this a non-implemented feature yet? (it is possible to use values from a spreadsheet as query parameters…)

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

9 additional answers

Sort by: Most helpful
  1. Lz365 38,191 Reputation points Volunteer Moderator
    2020-02-10T16:00:24+00:00

    OK Craig

    For the sample, do you want it with 1 or 2 drop downs? I'll explain later why this can make a difference

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Lz365 38,191 Reputation points Volunteer Moderator
    2020-02-10T14:04:42+00:00

    You're welcome. Let me know if you want a sample with DV drop-down(s) used a parameter(s) for query

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  3. Lz365 38,191 Reputation points Volunteer Moderator
    2020-02-08T18:55:23+00:00

    Hi Craig

    You were lucky I saw your post a week later. As your request is slightly different - in the sense it now involves Power Query - I took the freedom to split it as a new case/thread

    I will have a look to your queries tomorrow and will let you know how I feel about them

    Nice day...

    Was this answer helpful?

    0 comments No comments