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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
martinqb
New Member

Is this the correct use of Power Query?

I have dabbled quite a bit in Excel and VBA. I now try to learn about Power Query. I've come to realise that PowerQuery is mostly for data management/relations, whereas VBA should really only be used for cosmetic changes (as it takes a lot of processing power, correct me if I'm wrong). I'm starting to get a grasp of the concept, but I had a question:

Can PowerQuery replace index/match?

I have here two tables with the exact same information (using index/match). I didn't add anything new, other than different IDs. Would I be able to write a name in the secondary table and get the results from the primary table without the need for index/match?

I have attached screenshots of my excel file (I can't upload the actual file) to help me with this (I'm using it to learn more about power query).

I'm not interested (yet) in learning about power pivot though, as I see no need for pivot tables in my life.


Primary TablePrimary Table     Secondary Table (Index/Match by Name)Secondary Table (Index/Match by Name)

10 REPLIES 10
rubayatyasmin
Super User
Super User

Hi, @martinqb 

 

Yes, Power Query can replace the need for Index/Match in many scenarios, and it can be a more efficient and user-friendly way to manage data and perform lookups. Power Query is designed specifically for data transformation and manipulation tasks, including merging, filtering, and transforming data from multiple sources.

In your case, where you have two tables with the same information and want to perform lookups based on a common field (e.g., "Name"), Power Query can easily handle this. You can use Power Query to merge the two tables based on the "Name" column, effectively replicating the functionality of Index/Match.

Here's a general outline of the steps you would take in Power Query to replace Index/Match:

  1. Load both tables into Power Query: Import both the "Primary Table" and the "Secondary Table" into Power Query.

  2. Merge queries: In Power Query, you can use the "Merge Queries" option to merge the two tables based on the "Name" column. This will combine the data from both tables into a single table.

  3. Expand the results: After merging the queries, you may need to expand the results column, so you can see the values from the "Primary Table" that match the "Name" in the "Secondary Table."

  4. Transform data as needed: If required, you can further transform the data, such as renaming columns or removing unnecessary columns.

  5. Load the results: Once the data is transformed, you can load the results back into Excel or create a new worksheet with the updated data.

Power Query's approach is more streamlined and generally more efficient compared to using Index/Match formulas, especially when dealing with larger datasets. It also offers more flexibility in terms of data manipulation and data cleaning.

Remember that Power Query doesn't change the underlying data; it only creates a new query with the merged and transformed data. So, if your data in the "Primary Table" changes, you can easily refresh the Power Query to update the results.

 

GPT generated detailed reply. 

To learn more about using Power Query for data manipulation, see

 

https://learn.microsoft.com/en-us/power-query/

 

rubayatyasmin_0-1689517080227.png


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


 

I can also use ChatGPT:

 

------------------------------------------

Yes, you are correct in your understanding of the roles of Power Query and VBA in Excel.

Power Query (also known as Get & Transform in Excel) is primarily used for data preparation, transformation, and data management tasks. It provides a powerful and user-friendly interface to clean, reshape, and combine data from multiple sources. Power Query is highly efficient in handling large datasets and can perform various data operations quickly and with ease.

Regarding your question, yes, Power Query can replace the need for INDEX/MATCH in many cases. INDEX/MATCH is a popular Excel formula combination used to look up values in a table based on specific criteria. However, Power Query offers the "Merge" functionality, which can perform similar tasks more efficiently.

In Power Query, you can merge tables based on one or more columns, just like using INDEX/MATCH with multiple criteria. The process is called "Table Merge" or "Join" in Power Query. By using Merge, you can avoid complex array formulas and improve the readability and maintainability of your data transformations.

Here's a high-level example of how Power Query can replace INDEX/MATCH:

Let's say you have two tables: Table1 and Table2, and you want to pull a value from Table2 into Table1 based on a common key (e.g., ID).

Using INDEX/MATCH:

In Excel, you would write a formula like this in a cell of Table1:

=INDEX(Table2[DesiredColumn], MATCH([@ID], Table2[ID], 0))

Using Power Query:

  1. Load both Table1 and Table2 into Power Query as separate queries.
  2. Merge Table1 with Table2 based on the "ID" column.
  3. Expand the desired column from the merged table.
  4. Load the final transformed data back to Excel.

    By following these steps, you can achieve the same result as INDEX/MATCH but in a more organized and efficient manner.

    Power Query's strength lies in handling complex data relationships, joining tables, and applying transformations, making it a powerful tool for data management tasks. However, it's essential to know that both INDEX/MATCH and Power Query have their places in Excel, and there might be scenarios where one is more suitable than the other based on the specific requirements of your task.

    ------------------------------------------

     

    PeteGPT



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Yeah, perfect time saver. 😂


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


 

BA_Pete_0-1690888102723.png

 



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




MS made GPT public to utilize it. If you know the answer and provide it a context and askt it to write details answer. It will write it for you. Why write details answer when you can generate? 

 

I do not see any problem here. I am not denying the fact that I used GPT to generate detailed answer. I thought PQ could solve the problem and it's possible in PQ so I asked GPT to provide details. 

 

Why is this even an issue, I am not sure. If anyone asked me if I wrote it directly and I replied that I did then it would have been unethical. 

 

In community we help people the way we can. 

I thought of not writing details just write short summary of my thoughts and asked to write in details. I do not see an issue here. 

 

Hope I made my intentions clear. 

 

Again, I am not denying the fact that I used GPT. 

 

Proud to be a GPT user. 

 

 


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


 

Understood, but I think you should be up-front in your answer if using an AI response. Maybe prefix your answer with "From ChatGPT:" or similar.

 

I'm sure you wouldn't take a painting done by someone else to an art exhibition and put your own name on it, then expect everyone to be okay with "if you asked me if I painted it I would have told you I didn't" - same principle applies here.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Edited and added to the reply. 


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


 

Cool. Although it does feel as though you've written the artists' name really small on the side of the frame here and kept your name on the big label.

Put the credit up-front, something like this:

 

Hi @personAskingQuestion,

 

From ChatGPT:

------------------------------------------------------------

Yes, Power Query can replace the need for Ind....

hewgfurgiugruvrdauhrea

------------------------------------------------------------

 

To learn more about using Power Query for data manipulation, see...

<LINK>

 

 

I don't want to go on, but I think this is a really important discussion to have.

We could very feasibly get into a position where people are just copying questions into ChatGPT and posting the answers without ever understanding if they're even correct, let alone whether they're actually the most suitable solution for the overall problem. Literal answers to bad questions can cause even more problems in the long-run than answers that flat-out don't work.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




This is really a scene here. I made it bold. Bold words literally catches eye first. 

 

This is a debate really. I have agreed that yes, I used Gpt to generate detailed answer. Because I felt like this could be done using PQ. I made it very clear. I put summary answer and asked to generate detailed answer. 

 

But you sir, literally are not happy and dragging it. I accepted it edited it. Made bold so that it catches eye first. 

 

People answers different questions every time everyones answer is not correct. So, if I am wrong in this solution to think that PQ can do it then I am wrong. Whoever asking question will be accept the right solution I will know my mistake. 

 

This is a community where you can seek help or can help people. Right? 

Again I made my intentions clear and accepted the terms. 

 

Why dragging so long, I am not sure of. 

 

People can either use GPT to save time or waste their time. It's up to individual. It's public, anyone can use it. 

 

I usually write short answers but I personally do like elaborated answer so I used GPT. What's wrong with that I do not know. You mocked it first then dragged it then I proudly accepted that I did and edited my answer. 

 

But then again you have a problem. 

 

I am not debating anymore sir. I accepted my terms, I rectified it. 

 

But that does not make you happy then what else can I do, I do not know of. 

 

Thanks


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


 

Fair enough. Have a nice day.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.