How to filter rows in a table based on values in another table in power query

爷,独闯天下 提交于 2019-12-11 12:33:29

问题


I have two tables in power query.

Price table

Date       Company  Price
01/01/2000  A        10
01/02/2000  A        12
01/03/2000  A        15
01/01/2000  B        15
01/02/2000  B        85
01/03/2000  B        98 

Size table

 Date      Company  Size
01/06/2000  A        10
01/06/2001  A        12
01/06/2002  A        15
01/06/2000  B        15
01/06/2001  B        85
01/06/2002  B        98 

In Price table, I want only to have companies which are in size table. In other words, If company C is not in the size table, I do not need that company data points in the price table. Here no need to consider the date.


回答1:


In Power Query you can use the Merge Queries function to achieve that. (In the Home --> Combine section of the ribbon.

Select the Join Kind to determine which rows to keep.

In your example, create a query from the 2nd table and apply the following steps:

  • Remove the date and the size column
  • Remove duplicates

Afterwards you can join the first table with the newly created query and do a inner join. (Only keep matching entries)



来源:https://stackoverflow.com/questions/38500927/how-to-filter-rows-in-a-table-based-on-values-in-another-table-in-power-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!