Skip to main content

Notifications

Create Power Automate cloud flows
Suggested answer

How to extract non null values using xml in flow

Posted on by 6

Hi Everyone,

I am having difficulty filtering non-null values using XML. Here’s the situation: I am getting output from a "Filter array" action that is inside an "Apply to each" loop. Now, I need to filter out six columns and bring the non-null values into two different columns.

Here’s what I am expecting:

  • "What type of work does each level primarily engage in? - Choice 1 - ASE": "Testing"
  • "What type of work does each level primarily engage in? - Choice 2 - ASE": "Data and analytics"
  • "What type of work does each level primarily engage in? - Choice 1 - SE": "Development"
  • "What type of work does each level primarily engage in? - Choice 2 - SE": "Research"
  • "What type of work does each level primarily engage in? - Choice 1 - SSE": "Research"
  • "What type of work does each level primarily engage in? - Choice 2 - SSE": "Program Management"

I cannot use another "Apply to each" loop inside the existing one. I need a solution using XML. In this situation, I will get only two values out of the six columns/rows:

{"column1": "Testing", "column2": "Data and analytics", "column3": "", "column4": "Testing", "column5": ""}

Choice1: Testing
Choice2: Data and analytics

To be precise, I need to ignore null/blank values from the six columns and extract values from the columns where values are present.

Categories:
  • Suggested answer
    abm abm Profile Picture
    abm abm 32,046 on at
    How to extract non null values using xml in flow
    Hi
     
    Create a parse json something like this as schema
     
    {
      "type": "object",
      "properties": {
        "column1": { "type": "string" },
        "column2": { "type": "string" },
        "column3": { "type": "string" },
        "column4": { "type": "string" },
        "column5": { "type": "string" }
      }
    }
     
    Next add a compose action step and use the concat expression to check whether its blank or not.
     
    concat(
        if(equals(outputs('Parsed_JSON')?['column1'], ''), '', concat('column1: ', outputs('Parsed_JSON')?['column1'], '\n')),
        if(equals(outputs('Parsed_JSON')?['column2'], ''), '', concat('column2: ', outputs('Parsed_JSON')?['column2'], '\n')),
        if(equals(outputs('Parsed_JSON')?['column3'], ''), '', concat('column3: ', outputs('Parsed_JSON')?['column3'], '\n')),
        if(equals(outputs('Parsed_JSON')?['column4'], ''), '', concat('column4: ', outputs('Parsed_JSON')?['column4'], '\n')),
        if(equals(outputs('Parsed_JSON')?['column5'], ''), '', concat('column5: ', outputs('Parsed_JSON')?['column5'], '\n'))
    )
     
    Note: If its null then extend the type "string" like this.
    "column1": { "type": ["null", "string"] }
     
    Do the same for all the columns
     

     
  • Suggested answer
    FLMike Profile Picture
    FLMike 23,361 on at
    How to extract non null values using xml in flow
    Hi
     
    I do not understand what you mean you must use XML. You didn't share xlm, that is JSON, so I am confused.
     
    Please clarify as well as share your flow so we can see what you are trying to do, the data going into the actions and coming out.

Helpful resources

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 140,745

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,355

Leaderboard

Featured topics