PDA

View Full Version : PQ - Power Query: search multiple columns against a list of values?



sandy666
02-22-2021, 11:50 PM
(question from the web (https://www.mrexcel.com/board/threads/power-query-search-multiple-columns-against-a-list-of-values.1162596/#post-5644000))

I am trying to move an excel SUMPRODUCT function into Power Query.
The function searches a column against a list of names in a table, then returns TRUE if one is found.
Code sample:
IF ( SUMPRODUCT ( ISNUMBER ( SEARCH ( Table[Column], [@[current_field]] ) ) * ROW ( $rows included in Table[Column] ) ) >0, TRUE, FALSE )

There are seven (7) columns to check for each record so I put all of the separate SUMPRODUCT functions within an OR ( ) clause.
IF ( OR ( SUMPRODUCT ( ISNUMBER ( SEARCH ( Table[Column], [@[first_field]] ) ) * ROW ( $rows included in Table[Column] ) ) >0,
SUMPRODUCT ( ISNUMBER ( SEARCH ( Table[Column], [@[second_field]] ) ) * ROW ( $rows included in Table[Column] ) ) >0,
...
SUMPRODUCT ( ISNUMBER ( SEARCH ( Table[Column], [@[seventh_field]] ) ) * ROW ( $rows included in Table[Column] ) ) >0), TRUE, FALSE )

Does Power Query have an analogous function or functionality to accomplish this task?

Background: The report collects data in Excel then links to Access for table joins and processing.
I need to see if I can move this very manual report out of Access and completely into Excel.
1. forget about worksheet functions
2. change your mindset using Power Query
3. source tables and expected result table are very welcome
so...
here is supposed example of the result

NamesColumn1Column2Column3Column4Column5Column6Col umn7

abc
TRUE
FALSE
FALSE
FALSE
TRUE
TRUE
FALSE

def
FALSE
TRUE
FALSE
FALSE
FALSE
FALSE
TRUE

ghi
FALSE
FALSE
TRUE
FALSE
FALSE
TRUE
FALSE


https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)
https://eileenslounge.com/viewtopic.php?p=317218#p317218 (https://eileenslounge.com/viewtopic.php?p=317218#p317218)
https://eileenslounge.com/viewtopic.php?p=316955#p316955 (https://eileenslounge.com/viewtopic.php?p=316955#p316955)
https://eileenslounge.com/viewtopic.php?p=316955#p316955 (https://eileenslounge.com/viewtopic.php?p=316955#p316955)
https://eileenslounge.com/viewtopic.php?p=316940#p316940 (https://eileenslounge.com/viewtopic.php?p=316940#p316940)
https://eileenslounge.com/viewtopic.php?p=316927#p316927 (https://eileenslounge.com/viewtopic.php?p=316927#p316927)
https://eileenslounge.com/viewtopic.php?p=317014#p317014 (https://eileenslounge.com/viewtopic.php?p=317014#p317014)
https://eileenslounge.com/viewtopic.php?p=317006#p317006 (https://eileenslounge.com/viewtopic.php?p=317006#p317006)
https://eileenslounge.com/viewtopic.php?p=316935#p316935 (https://eileenslounge.com/viewtopic.php?p=316935#p316935)
https://eileenslounge.com/viewtopic.php?p=316875#p316875 (https://eileenslounge.com/viewtopic.php?p=316875#p316875)
https://eileenslounge.com/viewtopic.php?p=316254#p316254 (https://eileenslounge.com/viewtopic.php?p=316254#p316254)
https://eileenslounge.com/viewtopic.php?p=316280#p316280 (https://eileenslounge.com/viewtopic.php?p=316280#p316280)
https://eileenslounge.com/viewtopic.php?p=315915#p315915 (https://eileenslounge.com/viewtopic.php?p=315915#p315915)
https://eileenslounge.com/viewtopic.php?p=315512#p315512 (https://eileenslounge.com/viewtopic.php?p=315512#p315512)
https://eileenslounge.com/viewtopic.php?p=315744#p315744 (https://eileenslounge.com/viewtopic.php?p=315744#p315744)
https://www.eileenslounge.com/viewtopic.php?p=315512#p315512 (https://www.eileenslounge.com/viewtopic.php?p=315512#p315512)
https://eileenslounge.com/viewtopic.php?p=315680#p315680 (https://eileenslounge.com/viewtopic.php?p=315680#p315680)
https://eileenslounge.com/viewtopic.php?p=315743#p315743 (https://eileenslounge.com/viewtopic.php?p=315743#p315743)
https://www.eileenslounge.com/viewtopic.php?p=315326#p315326 (https://www.eileenslounge.com/viewtopic.php?p=315326#p315326)
https://www.eileenslounge.com/viewtopic.php?f=30&t=40752 (https://www.eileenslounge.com/viewtopic.php?f=30&t=40752)
https://eileenslounge.com/viewtopic.php?p=314950#p314950 (https://eileenslounge.com/viewtopic.php?p=314950#p314950)
https://www.eileenslounge.com/viewtopic.php?p=314940#p314940 (https://www.eileenslounge.com/viewtopic.php?p=314940#p314940)
https://www.eileenslounge.com/viewtopic.php?p=314926#p314926 (https://www.eileenslounge.com/viewtopic.php?p=314926#p314926)
https://www.eileenslounge.com/viewtopic.php?p=314920#p314920 (https://www.eileenslounge.com/viewtopic.php?p=314920#p314920)
https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=314837#p314837 (https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=314837#p314837)
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)