Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
I have a script it works online but when I add it to a power automate flow it is pulling in wrong data. I basically have an employee file with status. I want to filter off our various termed employees onto a separate sheet. Once it is ran through Power Automate essentially every employee is moved to the term list. We have roughly 10,000 employees and only a dozen or so people remain on the report. Any suggestions.
function main(workbook: ExcelScript.Workbook) {
const table = workbook.getTable("Table1");
const EmployeeStatusColumn = table.getColumnByName("Employee Status");
EmployeeStatusColumn.getFilter().applyValuesFilter(["Terminated","Backout","Fall off","Terminated w/Severance"]);
workbook.addWorksheet().getRange().copyFrom(table.getRange());
let sh: ExcelScript.Worksheet = workbook.getWorksheet("Report")
let visibleRows = table.getRangeBetweenHeaderAndTotal().getVisibleView().getRows()
let firstVisibleRow = visibleRows[0].getRange().getRowIndex() + 1
let lastVisibleRow = visibleRows[visibleRows.length - 1].getRange().getRowIndex() + 1
sh.getRange(`${firstVisibleRow}:${lastVisibleRow}`).delete(ExcelScript.DeleteShiftDirection.up)
table.getColumnByName("Employee Status")
.getFilter()
.clear();
}
Hi, @Syndicate_Admin ;
From your code found that there are filters, perhaps because the filter caused the data from 10,000 to a dozen employees, you try to remove the filter to check if this is the reason, if so, change the filter.
Run Office Scripts with Power Automate - Office Scripts | Microsoft Learn
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.