Home > Software design >  Power Apps: IsMatch not recognizing Forward Slash
Power Apps: IsMatch not recognizing Forward Slash

Time:12-11

Trying to have a label change its text value based on the input of two dropdowns.

enter image description here

I am using IsMatch to compare the dropdown options. The If statement works as intended (is applied to both dropdowns OnChange action) except for comparisons of strings that have a "/" but that is not listed as a special character to my understanding.

Code:

If(
    IsMatch(Dropdown1.Selected.Value,"ED (GE/ME/OE)") && 
    IsMatch(Dropdown3.Selected.Value,"Inpatient (GA/MA/OA)"), Set(transferType,"Transfer Type: Manage Transfer"),
    IsMatch(Dropdown1.Selected.Value,"L&D") && 
    IsMatch(Dropdown3.Selected.Value,"PEADS"), Set(transferType,"Transfer Type: Manage Transfer"),
    Set(transferType,"Transfer Type: Don't Know"))

Dropdown 1 item list:

["ED (GE/ME/OE)",
"Medicine/Surgery/Postpartum (GA/MA/OA)",
"Surgery (GS/MS/OS)",
"L&D",
"Postpartum Baby (GA/MA/OA)",
"PACU (GS/MS/OS)",
"Paeds to/from (OA)",
"Outpatient Surgery/PACU (GS/MS/OS)",
"Medicine/Surgery (GA/MA/OA)",
"Mental Health (OP)",
"ICU (GA/MA/OA)",
"Inter-site transfer within
Halton Healthcare (e.g. GH
medicine)",
"Direct Admit e.g. Community",
"Repatriation e.g. THP"]

Dropdown 2 item list:

["Inpatient (GA/MA/OA)",
"ICU (GA/MA/OA)",
"Medicine (GA/MA/OA)",
"PACU (GS/MS/OS)",
"Postpartum (GA/MA/OA)",
"SCN (GA/MA/OA)",
"Inpatient Paeds (GA/MA/OA)",
"CAPIS",
"PEADS",
"CTC/Rehab (GC/MC/OC)",
"Mental Health (OP)",
"Med/Surg (GA/MA/OA)"]

CodePudding user response:

Realized I forgot that the () were special characters (thank you @Wiktor). Solution worked with: IsMatch(Dropdown1.Selected.Value,"ED \(GE/ME/OE\)"

CodePudding user response:

The function IsMatch checks for regular expressions, and as mentioned in a comment, the ( and ) characters have special meanings and need to be escaped. In your case you don't seem to need a regular expression - you know exactly what the value should be, so you can use the = operator to compare the values instead:

If(
    Dropdown1.Selected.Value = "ED (GE/ME/OE)" && Dropdown3.Selected.Value ="Inpatient (GA/MA/OA)",
        Set(transferType, "Transfer Type: Manage Transfer"),
    Dropdown1.Selected.Value ="L&D" && Dropdown3.Selected.Value = "PEADS", 
        Set(transferType, "Transfer Type: Manage Transfer"),
    Set(transferType,"Transfer Type: Don't Know"))
  • Related