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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Use individual results...
Power Automate
Unanswered

Use individual results from SQl query

(0) ShareShare
ReportReport
Posted on by 22

Hi all,

 

I have looked everywhere and can't find the answer to what I assume is something very basic that I am missing.

I have an sql query that runs in my flow, it pulls back 5 rows only. I want to use the outputs from this query in a post on teams. Which I believe would be best done through a variable. How would I initialise a variable for effectively each combination of message type and each other column? 

 

For example: 

SQL query results:

JoeColvile_0-1626837401259.png

[
 {
 "MessageType": "Adjustment",
 "ErrorMessages": 0,
 "ErrorMessageLines": 0,
 "ReceivedLines": 2,
 "ReceivedMessages": 2
 },
 {
 "MessageType": "LoadReceipt",
 "ErrorMessages": 0,
 "ErrorMessageLines": 0,
 "ReceivedLines": 6,
 "ReceivedMessages": 2
 },
 {
 "MessageType": "Movement",
 "ErrorMessages": 0,
 "ErrorMessageLines": 0,
 "ReceivedLines": 91,
 "ReceivedMessages": 91
 },
 {
 "MessageType": "PickList",
 "ErrorMessages": 2,
 "ErrorMessageLines": 4,
 "ReceivedLines": 7,
 "ReceivedMessages": 3
 },
 {
 "MessageType": "TransferReceipt",
 "ErrorMessages": 0,
 "ErrorMessageLines": 0,
 "ReceivedLines": 13,
 "ReceivedMessages": 4
 }
]

 

What I want to do is be able to use each of the elements as separate variables (e.g. Transfer receipt error messages = 0)

 

How would I achieve this?

 

Categories:
I have the same question (0)
  • Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at

    Hi @JoeColvile 

    are you using PAD or microsoft flow?

  • JoeColvile Profile Picture
    22 on at

    I am using Power Automate - triggered flow

  • Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at

    May i know in what format u need to post this message in teams, should it be posted as every record or combination of all records in once,?

  • JoeColvile Profile Picture
    22 on at

    The aim is to post a health update so I want to write something like:

     

    Today there have been x amount of errors.

     

    For each message type below are the messages received/ error messages:

     

    Load receipt x/x

    Pick registration x/x

     

     

    X is my variable

  • Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at

    Well we can do this as well, but i need a clarification on variable x what does it should contain, do it should all data corresponding to each message type?

  • JoeColvile Profile Picture
    22 on at

    Variable should be a string. I want a variable containing the picklist  error message, then another for picklist received lines ect. So basically the individual results from the table I showed.

  • Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at

    Hi @JoeColvile sorry to ask you again, 

    Nived_Nambiar_0-1626893542436.png

    As i highlighted in the above figure, do u need error messages indiviually and total too ? am i right?

  • JoeColvile Profile Picture
    22 on at

    Yes I want each of those to be its own variable that I am able to use. For example Variable1 =  0 (Adjustment, error messages)

  • Verified answer
    Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at

    Well i got answer for your question 

     

    see the result 

     

    Nived_Nambiar_0-1626959835688.png

     

     

    What i did 

     

    1. sql result is coming in json format , so the first step used Parse Json activity and parse the json and store in a variable.

     

    2. Now using body parameter of Parse JSON action , extracted the required data for each type 

     

    see below

     

    Adjustment Error Message : 

    body('Parse_JSON')?[0]?['ErrorMessages']
     
    Load Reciept : 
    body('Parse_JSON')?[1]?['ErrorMessages']
     
    Movement : 
    body('Parse_JSON')?[2]?['ErrorMessages']
     
    PickList : 
    body('Parse_JSON')?[3]?['ErrorMessages']
     
    Transfer Reciept : 
    body('Parse_JSON')?[4]?['ErrorMessages']
     
    i used compose action for above 
     
    Next i add these error message together to get the sum of error messages [ used add function, it can add only 2 numbers at a time.
     
    Next, used the post message to team with the below format
     
    Nived_Nambiar_1-1626960123331.png

     

     

    And it worked successfully as required!!!!!

     

    Let me know if you need any further help around this 

     

    screenshot of entire workflow

    Nived_Nambiar_2-1626960192127.png

     

    Nived_Nambiar_3-1626960207241.png

     

     

    Mark it as solution if it helps !!!!!!

     

    Regards,

     

    Nived N

  • JoeColvile Profile Picture
    22 on at

    This works, thank you!

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard