Compare columns

sharshra

Active Member
Joined
Mar 20, 2013
Messages
352
Office Version
  1. 365
I have to compare 2 columns & get the result in another column. I´m using FILTER function but not getting the correct results. I'm sure I must have done some mistake. Can the experts help please?

Scenario - I have a table (source table) with 3 columns - name, C, L. Columns C & L are not filled for all names. In the column 'both´, I want to get the names where both columns C & L are not empty. If one either C or L is empty, both column will be blank. The results should be as shown in the desired output table.

I have used FILTER function, but not getting the required output. Is there a better way to get the desired output?

2nd part is to use dynamic array formula to get the same result.

Source table:
excel problems.xlsx
OPQ
2nameCL
3ffafdsffafdsffafds
4qewqqewq
5tyerytyerytyery
6ryutryut
7hjghjghjg
8zvzvczvzvc
9vncvnc
10gsdggsdg
11fhdfhdfhd
12fjggfjggfjgg
13lghllghl
Sheet2


Desired output:
excel problems.xlsx
OPQR
2nameCLboth
3ffafdsffafdsffafdsffafds
4qewqqewq
5tyerytyerytyerytyery
6ryutryut
7hjghjghjghjg
8zvzvczvzvc
9vncvnc
10gsdggsdg
11fhdfhdfhdfhd
12fjggfjggfjggfjgg
13lghllghl
Sheet2


Incorrect result with FILTER formula:
excel problems.xlsx
UVWX
2nameCLboth
3ffafdsffafdsffafdsffafds
4qewqqewqqewq
5tyerytyerytyerytyery
6ryutryutryut
7hjghjghjghjg
8zvzvczvzvczvzvc
9vncvncvnc
10gsdggsdggsdg
11fhdfhdfhdfhd
12fjggfjggfjggfjgg
13lghllghllghl
Sheet2
Cell Formulas
RangeFormula
X3:X13X3=FILTER($O$3:$O$13,(P3<>"")*(Q3<>""))
Dynamic array formulas.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Hello, you could e.g. try:

Excel Formula:
=IF(ISBLANK(P2:P12)+ISBLANK(Q2:Q12)=0,O2:O12,"")
 
Upvote 0
Thanks, @hagia_sofia. In the actual table, even when there is blank cell, ISBLANK returns FALSE. Not sure why it happens. It works well in the sample table shared in this post :oops:

I thought it should be possible with FILTER function, but it is not working. When I filter on blank, it recognized the blank cells as blank, but not in the formula. Is there any other ways other than checking for BLANK?

Or any suggestions from experts why ISBLANK returns FALSE when it is actually blank?
 
Upvote 0
It is possible that it is not blank: does CODE(P3:Q3) return error for every blank cell?
 
Upvote 0
Alright, how about this:

Excel Formula:
=IF(LEN(P2:P12)*LEN(Q2:Q12)>0,O2:O12,"")
 
Upvote 1
Solution
an option with Power Query

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"name", type text}, {"C", type text}, {"L", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if([C]=[L]) then [C] else null)
in
    #"Added Custom"
 
Upvote 1

Forum statistics

Threads
1,221,510
Messages
6,160,230
Members
451,632
Latest member
purpleflower26

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top