Home > other >  How to add a Two Column Unique without ruining my Query?
How to add a Two Column Unique without ruining my Query?

Time:09-30

This code works perfectly aside from one entry having the same name and therefore not making it into the outcome. It returns all 8 requested Columns in the order expected.

=ARRAYFORMULA(Query(IFERROR(VLOOKUP(UNIQUE(T7IG!F:F),
  QUERY({T7IG!$A:$Q},"select Col6, Col1, Col3, Col4, Col7, Col10, Col11, Col15 
  WHERE Col10 = 1 Order By Col15 Desc",1),{1, 2, 3, 4, 5, 6, 7, 8},
  FALSE)),"SELECT Col2, Col3, Col4, Col1, Col5, Col6, Col7, Col8"))

I added to the UNIQUE condition making it check 2 Columns so I get both entries with the same name. Unfortunately this makes it return only the 4th Column (The information in the inner QUERY identified as Col6, and in the outter QUERY as Col1), not the entire Query. Meaning the first 3 Columns and the last 4 do not appear when the Code is run. Only the 4th Column is generated and it's in the Column it should appear. All other Columns are blank.

=ARRAYFORMULA(Query(IFERROR(VLOOKUP(UNIQUE(T7IG!F:G),
  QUERY({T7IG!$A:$Q},"select Col6, Col1, Col3, Col4, Col7, Col10, Col11, Col15 
  WHERE Col10 = 1 Order By Col15 Desc",1),{1, 2, 3, 4, 5, 6, 7, 8},
  FALSE)),"SELECT Col2, Col3, Col4, Col1, Col5, Col6, Col7, Col8"))

Any idea what I could do to make this work?

*I'm sorry if this question seems vague or perhaps is not clear, but that's because the issue that is caused by adding another column to the UNIQUE function makes no sense to me at all.

CodePudding user response:

try:

=ARRAYFORMULA(QUERY(IFERROR(VLOOKUP(UNIQUE(T7IG!F:F&T7IG!G:G),
 QUERY({T7IG!F:F&T7IG!G:G, T7IG!$A:$Q},
 "select Col1,Col7,Col2,Col4,Col5,Col8,Col11,Col12,Col16 
  where Col11 = 1 
  order by Col16 desc", 1), {2,3,4,5,6,7,8,9}, 0)),
 "select Col2,Col3,Col4,Col1,Col5,Col6,Col7,Col8", 1))

enter image description here

  • Related