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 Automate / Manipulating data stor...
Power Automate
Answered

Manipulating data stored in a Microsoft Power Automate variable

(0) ShareShare
ReportReport
Posted on by 13

Hello,

 

I am trying to find the largest number within a list stored in a Microsoft Power Automate Variable. Is there any way to do this without linking to the web version? 

 

Here is an example, I am using the Extract Data from web page action to find html attributes from a web page. The results are a list beginning with 1 with 0.1 increments as subcategories of events on the web page. In this case, I would like to store 2 in a microsoft power automate variable as the largest whole number integer within this list. Thank you in advance for your help!

colews18_0-1680641089754.png

 

  • colews18 Profile Picture
    13 on at

    I have attempted to use the Run JavaScript function on web page action to find the largest whole number in the list but this action seems to only return text instead of numbers.

    colews18_0-1680641990356.png

     

    code for reference:
    // Get the element by its id
    const element = document.querySelector('#id');

    // Select the desired element using the CSS selector
    const selectedElement = element.querySelector('html > body > div > div > div > div:eq(1) > table > tbody > tr > td:eq(2) > div > table > tbody > tr > td > table > tbody > tr > td > div > div > div:eq(1) > ul > li');

    // Extract the text content and convert it to an array of numbers
    const numbers = selectedElement.textContent.trim().split(' ').map(num => parseInt(num));

    // Find the greatest whole number integer in the array
    const greatestInteger = Math.max(...numbers.filter(num => Number.isInteger(num)));

    // Check if the greatestInteger is a numeric value
    if (isNaN(greatestInteger)) {
      console.log('The selected element does not contain any numeric values.');
    } else {
      console.log('The greatest whole number integer in the selected element is:', greatestInteger);
    }

     

  • Gidi Profile Picture
    601 on at

    Hi, 

    have you tried to create a loop and compare each row with the current max value found and for getting the integer part of the number you can use the action truncate number. 

  • colews18 Profile Picture
    13 on at

    Hi @Gidi, thanks for the reply. That was a solution that I thought of but couldn't figure out how to do this since the list was stored in the variable. What desktop actions would I use to compare each row within the variable list? This is basically what I did with the JS code but not sure how to replicate this with Power Automate flows. Thanks!

  • Verified answer
    colews18 Profile Picture
    13 on at

    Hi @Gidi I just figured it out! I actually converted the datatable to a list first, reversed the list and then used set a new variable as the first item in the list. Here is the syntax I used to select the first item in the list. %ColumnAsList[0]%. Thanks for the help!

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 Automate

#1
11manish Profile Picture

11manish 249 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 202

#3
David_MA Profile Picture

David_MA 180 Super User 2026 Season 2

Last 30 days Overall leaderboard