web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Filter Gallery based o...
Power Apps
Answered

Filter Gallery based on partial match

(0) ShareShare
ReportReport
Posted on by 20

Hello,

 

I have been reading dozens of posts over the past several days and cannot seem to figure out a solution for the scenario I have.

 

I have a DataSource1 which tracks errors that are added through an automation from emails. I have a DataSource2 which has the solutions to the errors. The automation writes the error into a column which reads in text label "Error". I am trying to either have a nested gallery or text label that displays the solution based on the error presented but the problem is that the error is not an exact match every time as certain parts of it are variable numbers like ages or guest numbers.

 

I have tried a variety of formulas on galleries and text labels including Lookup, Filter, MatchAll, StartsWith, Split but none of them do what I need.

 

One formula that I have right now is below. It doesn't give errors but doesn't do what I need it to. I got to this formula by trying to strip out some of the variables that occur in the error message.

 

 

Filter(
 DataSource2,
 First(
 Split(
 Last(
 Split(
 Error.Text,
 "Order: "
 )
 ).Result,
 "Age = "
 )
 ).Result in DataSource1.Error || First(
 Split(
 Last(
 Split(
 Error.Text,
 "Order: "
 )
 ).Result,
 "only valid for sale from "
 )
 ).Result in DataSource1.Error
)

 

 

Can anyone think of a way to accomplish what I need?

Categories:
  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Dusty_Gregs :

    Could you provide some demo data for DataSource2 and DataSource1?For example:

    ClearCollect(
     DataSource2,
     {ID:1,Error:{Text:"Error1 Order: 1 only valid for sale from Age = 15 Test1"}},
     {ID:2,Error:{Text:"Error1 Order: 3 valid for sale from Age = 4 Test1"}},
     {ID:3,Error:{Text:"Error2 Order: 9 valid for sale from Age = 15 Test2"}},
     {ID:4,Error:{Text:"Error2 Order: 2 valid for sale from Age = 23 Test2"}},
     {ID:5,Error:{Text:"Error3 Order: 32 valid for sale from Age = 24 Test3"}},
     {ID:5,Error:{Text:"Error3 Order: 45 valid for sale from Age = 543 Test3"}}
    );
    ClearCollect(
     DataSource1,
     {Error:"Error1 Order:XX Age = XXX Test1"},
     {Error:"Error3 Order:XX Age = XX Test3"}
    )

    Because based on this information alone, I can not tell what the problem is with the formula.

    In addition, you could try this formula (Not necessarily work):

    Filter(
     DataSource2,
     First(
     Split(
     Last(
     Split(
     Error.Text,
     "Order: "
     )
     ).Result,
     "Age = "
     )
     ).Result in Concat(DataSource1,Error) || First(
     Split(
     Last(
     Split(
     Error.Text,
     "Order: "
     )
     ).Result,
     "only valid for sale from "
     )
     ).Result in Concat(DataSource1,Error)
    )

    Best Regards,

    Bof

  • Dusty_Gregs Profile Picture
    20 on at

    Hello @v-bofeng-msft,

     

    Thank you for the help so far! I did try adding Concat() where you mentioned and it is not working as I need it to. It displays the column from DataSource2 like I want but shows the entire gallery and does filter based on the error presented. Here are some examples for the data sources.

     

    DataSource1 (New errors. I bolded and underlined the variables.)

    1. Exception in TransmitOrder: Item only valid for sale from 11/23/2018 to 03/27/2021 per Item restriction.
      1. Exception in TransmitOrder: Item only valid for sale from 11/23/2018 to 03/30/2021 per Item restriction.
    2. Exception in TransmitOrder: Guest failed age limit check: Age = 1.764, Min = 11.000, Max = 99.000
      1. Exception in TransmitOrder: Guest failed age limit check: Age = 10.082, Min = 8.000, Max = 9.999
      2. Exception in TransmitOrder: Guest failed age limit check: Age = 69.247, Min = 69.250, Max = 79.999
    3. Exception in TransmitOrder: Item can only be sold between 00:00 and 11:45 per Item restriction.
    4. Exception in TransmitOrder: Item ADV-CAMPS ADV-CP-S SAC-S2-WK2 must have between 1 and 99 modifiers, and 0 are specified
      1. Exception in TransmitOrder: Item OMNI000014COMBOTIMES1030 must have between 1 and 1 modifiers, and 0 are specified

    DataSource2 (Errors for reference. There is a separate column for Solutions to the error which is what I would like to display)

    1. Exception in TransmitOrder: Item only valid for sale from XX/XX/XXXX to XX/XX/XXXX per Item restriction.
    2. Exception in TransmitOrder: Guest failed age limit check: Age = XXX.XXX, Min = XXX.XXX, Max = XXX.XXX
    3. Exception in TransmitOrder: Item can only be sold between XX:XX and XX:XX per Item restriction.
    4. Exception in TransmitOrder: Item XXXX must have between XX and XX modifiers, and XX are specified

     

    If it is easier to remove the variables from DataSource2 and split the errors coming in, that is definitely a possibility as the verbiage for DataSource2 without the variables should still be unique per error. 

     

    I also think having a text label using Lookup or something else may be what I actually need since each filter should only return 1 result. But I was unable to figure that out as well.

     

    I appreciate your help in looking into this!

     

    Thank you,

    Dusty

  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Dusty_Gregs :

    I assume these are datasouce1 and datasource2:

    ClearCollect(
     DataSource1,
     {ID:1,Error:{Text:"Exception in TransmitOrder: Item only valid for sale from 11/23/2018 to 03/27/2021 per Item restriction."}},
     {ID:2,Error:{Text:"Exception in TransmitOrder: Item only valid for sale from 11/23/2018 to 03/30/2021 per Item restriction."}},
     {ID:3,Error:{Text:"Exception in TransmitOrder: Guest failed age limit check: Age = 1.764, Min = 11.000, Max = 99.000"}},
     {ID:4,Error:{Text:"Exception in TransmitOrder: Guest failed age limit check: Age = 10.082, Min = 8.000, Max = 9.999"}},
     {ID:5,Error:{Text:"Exception in TransmitOrder: Item can only be sold between 00:00 and 11:45 per Item restriction"}},
     {ID:5,Error:{Text:"Exception in TransmitOrder: Item OMNI000014COMBOTIMES1030 must have between 1 and 1 modifiers, and 0 are specified"}}
    );
    ClearCollect(
     DataSource2,
     {Error:"Exception in TransmitOrder: Item only valid for sale from XX/XX/XXXX to XX/XX/XXXX per Item restriction."},
     {Error:"Exception in TransmitOrder: Guest failed age limit check: Age = XXX.XXX, Min = XXX.XXX, Max = XXX.XXX"},
     {Error:"Exception in TransmitOrder: Item can only be sold between XX:XX and XX:XX per Item restriction."},
     {Error:"Exception in TransmitOrder: Item XXXX must have between XX and XX modifiers, and XX are specified"}
    )

    Please try this formula:

    Filter(
     DataSource2,
     TrimEnds(
     Substitute(
     Substitute(
     Substitute(
     Substitute(
     Substitute(
     Substitute(
     Substitute(
     DataSource2[@Error],
     "XX/XX/XXXX",
     ""
     ),
     "XXXX ",
     ""
     ),
     "XXX.XXX",
     ""
     ),
     "XX:XX",
     ""
     ),
     ":",
     ""
     ),
     "XX",
     ""
     ),
     ".",
     ""
     )
     ) in ForAll(
     DataSource1,
     With(
     {
     thevalue: Concat(
     MatchAll(
     Error.Text,
     "[a-zA-Z= ,]+"
     ).FullMatch,
     FullMatch
     )
     },
     TrimEnds(
     If(
     Len(
     Match(
     thevalue,
     "(?<= Item ).*?(?=must)"
     ).FullMatch
     ) > 0,
     Replace(
     thevalue,
     Match(
     thevalue,
     "(?<=Item).*?(?=must)"
     ).StartMatch,
     Len(
     Match(
     thevalue,
     "(?<= Item ).*?(?=must)"
     ).FullMatch
     ),
     ""
     ),
     thevalue
     )
     )
     )
     )
    )

    Best Regards,

    Bof

  • Dusty_Gregs Profile Picture
    20 on at

    That worked beautifully! Thank you so much for your help @v-bofeng-msft!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 312

#3
Mohsin Ali Profile Picture

Mohsin Ali 252

Last 30 days Overall leaderboard