Using Xlookup with multiple criteria while checking if it contains text, instead of just exact matching

I am sure this may be a bit confusing, but I have a database similar to this screenshot:

What I want to do is, based on the data on “Info” ranges, apply a value to the Value ranges. For that I had formulas such as =if(A1 = "A", 1, 0) or =if(and(B1 = "red", C1 = "pear"), 1, 0) which would get me the second screenshot:

My problem is, I need to have these criteria as something easy accessible and modifiable for the user, for that I made another sheet that has the criteria, like the third image.

Another problem I can have is that, instead of getting just fruits in “Info3”, I might get say “pear juice”, and I would need that to be considered as “pear” too.

I first thought of using XLOOKUP to build a formula that would check if its line fit any of the criteria listed on the other table and then pull the value from the respective Value range, but I couldn’t think of a way to have it work with the ones with complex criteria, like the “red and pear”

I know that you can use a XLOOKUP with multiple criteria using something like this:

=XLOOKUP($A2&$B2&$C2,Criteria!$A$2:$A$3&Criteria!$B$2:$B$3&Criteria!$C$2:$C$3,Criteria!E$2:E$3,0)

The problem with this is that it wont work with the lines that only need to match with a single criteria, like the “A1 = A” that I mentioned.

For the “pear juice” part, something like this could work, but I don’t know how to have all of those working together.

=XLOOKUP(1,--ISNUMBER(SEARCH("pear",Criteria!$C$2:$C$3)),Criteria!E$2:E$3,2)

I also tried using this, but the “and” function returns 0 since not the “–ISNUMBER” returns both zeros and ones.

=XLOOKUP(1,AND(--ISNUMBER(SEARCH(Criteria!A2:A3,A14)),--INSNUMBER(SEARCH(Criteria!B2:B3,B14)),--ISNUMBER(SEARCH(Criteria!C2:C3,C14))),Criteria!E2:E3,0)

The database is also on PowerQuery, so if there is an easier way to do it there it would be great.

3

Assumptions:

  • A1: Value to match in Info1
  • B1: Value to match in Info2
  • C1: Value to match in Info3
  • All_Combos4: A table containing the Values for each combination of Values

To match on the “partial matches” assuming they will only occur in Info3, you can use the following formula:

=TAKE(
    FILTER(
        All_Combos4,
        (All_Combos4[Info1] = A1) *
            (All_Combos4[Info2] = B1) *
            ISNUMBER(
                SEARCH("*" & All_Combos4[Info3] & "*", C1)
            )
    ),
    ,
    -4
)

Database

Partial All_Combos4 Table

Single Row Example

Here is Power Query M Code that also looks up the matching values from the All_Combos table.

In the code below, your first table (database) is named Table1. You will need to change that to reference whatever your database really is.

Also note that, since there were only three value columns, I just coded each column separately, but this could be made more dynamic depending on your actual data.

Also, this code allows multi-word phrases in both Info2 and Info3. This should be changed if Info2 will never have a multiword phrase.

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{
        {"Info1", type text}, {"Info2", type text}, {"Info3", type text}}),
    
    #"Add Value1" = Table.AddColumn(#"Changed Type","Value1", (r)=>
        Table.SelectRows(All_Combos, each [Info1] = r[Info1]
                                            and List.Contains(Text.Split(r[Info2]," "),[Info2])
                                            and List.Contains(Text.Split(r[Info3]," "),[Info3])){0}[Value1], Percentage.Type),
    
    #"Add Value2" = Table.AddColumn(#"Add Value1","Value2", (r)=>
        Table.SelectRows(All_Combos, each [Info1] = r[Info1]
                                            and List.Contains(Text.Split(r[Info2]," "),[Info2])
                                            and List.Contains(Text.Split(r[Info3]," "),[Info3])){0}[Value2], Percentage.Type),
    
    #"Add Value3" = Table.AddColumn(#"Add Value2","Value3", (r)=>
        Table.SelectRows(All_Combos, each [Info1] = r[Info1]
                                            and List.Contains(Text.Split(r[Info2]," "),[Info2])
                                            and List.Contains(Text.Split(r[Info3]," "),[Info3])){0}[Value3], Percentage.Type),
    
    #"Add Sum Values" = Table.AddColumn(#"Add Value3","Sum", each List.Sum(List.LastN(Record.FieldValues(_),3)), Percentage.Type),
    #"Reordered Columns" = Table.ReorderColumns(#"Add Sum Values",{"Info1", "Info2", "Info3", "Sum", "Value1", "Value2", "Value3"})

in
    #"Reordered Columns"

0

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật