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!
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!
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!
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.
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.
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);
}
Michael E. Gernaey
497
Super User 2025 Season 2
David_MA
436
Super User 2025 Season 2
Riyaz_riz11
244
Super User 2025 Season 2