In Logic Apps I need to filter an array but the values are upperlowercase, how can I filter using an operator that doesn't require case sensitive value?

Duquette, Timothy 20 Reputation points
2024-05-10T22:00:18.2933333+00:00

In Logic Apps I need to filter an array, but the values are upper lowercase. My variable is all lower case.

How can I filter using an operator that doesn't require case sensitive value?

Or I need to convert array to all lowercase, how can I do that?

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,899 questions
0 comments No comments
{count} votes

Accepted answer
  1. hossein jalilian 4,205 Reputation points
    2024-05-11T00:36:33.37+00:00

    Thanks for posting your question in the Microsoft Q&A forum.

    • You can use the toLower() function to convert both the array elements and the variable to lowercase before comparing them.
        {
            "FilterArray": {
                "inputs": {
                    "from": "@variables('YourArrayVariable')",
                    "where": "@equals(toLower(item()), toLower(variables('YourVariableToCompare')))"
                },
                "runAfter": {},
                "type": "Query"
            }
        }
      
    • If you need to convert the entire array to lowercase before filtering, you can use the map() function along with toLower()
        {
            "ConvertToLowercase": {
                "inputs": {
                    "from": "@variables('YourArrayVariable')",
                    "select": {
                        "value": "@toLower(item())"
                    }
                },
                "runAfter": {},
                "type": "Query"
            }
        }
        
      

    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. MayankBargali-MSFT 69,581 Reputation points
    2024-05-13T13:22:20.7833333+00:00

    @Duquette, Timothy Thanks for reaching out.

    You should use the item as below for your filter array for your JSON object to compare with any of the property.

    "Filter_array": {
                    "inputs": {
                        "from": "@variables('myinput')",
                        "where": "@equals(toLower(item()['resourceType']), toLower(variables('compare')))"
                    }
    

    User's image

    I have validated the same with your custom JSON object and it return only the element which has availabilitysets value (ignoring case) for the resourceType property in your JSON object as below.

    User's image

    For more details you can refer to this document.

    Let me know if you still face any issue and I will be happy to assist you.

    Please click on 'Yes' if it helped so that it can help others in the community looking for help on similar topics.

    1 person found this answer helpful.

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more