Here's an example
let countA = 0; let countB = 0; let countC = 0;
for (let i = 0; i < usedRange; i++) { if (!range.getCell(i, 0).getHidden()) { if (i < 10) { countA++; } else if (i < 20) { countB++; } else { countC++; } } }
console.log("countA: " + countA); console.log("countB: " + countB); console.log("countC: " + countC);
// Create object with named variables let outputObj = { CountA: countA, CountB: countB, CountC: countC };
// Set output to object return outputObj;
You can then use the output of this script in Power Automate as follows:
set(variables('excelOutput'), outputs('Run_script')?[' body'])
This will store the output of the "Run script" action in a variable called "excelOutput".
To use the individual counts in other actions in your flow, you can add "Compose" actions for each count and enter the following expressions to retrieve the count from the "excelOutput" variable:
variables('excelOutput')['CountA'] variables('excelOutput')['CountB'] variables('excelOutput')['CountC']