简体   繁体   中英

Add a column in a table visual by comparing two columns from different power query tables and then possibly apply a filter (Power BI)

I am doing a Power BI project. I have a table with the following structure in a table visual:

C0 C1     C2 

A 2013  2013

A 2014  2013

A 2015  2013

A 2013  2014

A 2014  2014

A 2015  2014

A 2013  2015

A 2014  2015

A 2015  2015

B 2013  2013

B 2014  2013

B 2015  2013

B 2013  2014

B 2014  2014

B 2015  2014

B 2013  2015

B 2014  2015

B 2015  2015

C1 and C2 are taken from two different table sources. I only need the rows where C1==C2.

I would like the following:

C0 C1 C2 

A 2013 2013

A 2014 2014

A 2015 2015

B 2013 2013

B 2014 2014

B 2015 2015

I would like to compare th columns C1 and C2 and apply an appropriate filter. I was not able to create an appropriate measure, since these two columns are not from the same table source. A relationship between the underlying two tables exists, indirectly. The table of C1 is related to the table of C0. Similarly, the table of C2 is related to the table of C0. Can you help?

Go to Power Query Editor

First create a new column in the table with this below code-

= Value.Compare([C1],[#"C2 "])

The above will generate -1,0 and 1 in the new column. Now, just filter the column and keep rows only when value is 1. The output will be as bwlow-

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM