I have a flow where I am trying to return a value that is being calculated based off two inputs received from PVA bot to excel. I enter in the Specialty and the Percentile value and it returns the dollar value. When I just use the excel results dynamic action it works but as soon as I try to dollar format it it fails to bring in anything to the PVA bot.
Here is my script:
async function main(workbook: ExcelScript.Workbook, specialty: string, perc: string): Promise<string> {
// Access the worksheet named 'Percentile Input'.
let worksheet = workbook.getWorksheet('Percentile Input');
// Set the medical specialty in cell D2 based on the variable 'specialty'.
let specialtyCell = worksheet.getRange('D2');
specialtyCell.setValue(specialty);
// Set the percentile value in cell D11 based on the variable 'perc'.
let percCell = worksheet.getRange('D11');
percCell.setValue(parseFloat(perc.replace(/[^0-9.]+/g, ""))); // Remove any non-numeric characters before setting.
// Retrieve the calculated percentile from cell I11.
let percentileCell = worksheet.getRange('I11');
let percentileValue = percentileCell.getValue();
// Format the percentile value as a dollar value.
let formattedValue = `$${percentileValue.toFixed(2)}`; // Assuming two decimal places for cents
// Log the formatted value to the console.
console.log("Formatted Value:", formattedValue);
// Return the formatted percentile value as a string.
return formattedValue;
}
Here is my flow
I am trying to format the value that comes from the output of the script but the bot fails.
formatNumber(float(outputs('Run_script')?['body/result']), '$#,##0.00')
When I change to result it works:
I don't understand why it doesn't like the formatting, is it because it is coming in as a string? Is there anyway I can format this so I can bring it to the bot?
I think it something silly that I cannot figure out.
I tried this as well and it didnt work.
formatNumber(float(outputs('Run_script')?['body/result']), '0,0.00', 'en-us')
I tried your solution, and it did not work but then I tried the Format data by examples again and that seem to work. So switching it to text made a difference. This is what I used.😄
formatNumber(float(outputs('Run_script')?['body/result']), '$#,##0.00')
Hi @wherdzik ,
I've made a test, and encountered the problem you mentioned. Please choose 'Text' as the type of output and your formula will work(formatNumber(float(outputs('Run_script')?['body/result']), '0,0.00', 'en-us')).
Best Regards,
Bof
Artur Stepniak
5
Super User 2025 Season 1
Ekta Gupta
4
Michael E. Gernaey
4
Super User 2025 Season 1