You can use the in function in combination with array to check if a specific part of your file name is within a predefined list of values.
@in(substring(@item().name, indexOf(@item().name, 'Payroll_Detail_') + len('Payroll_Detail_'), indexOf(@item().name, '_', indexOf(@item().name, 'Payroll_Detail_') + len('Payroll_Detail_')) - indexOf(@item().name, 'Payroll_Detail_') - len('Payroll_Detail_')), array('LosAngeles', 'NewYork', 'SanFrancisco', ...))
The indexOf function to find the index of the specific pattern 'Payroll_Detail_' in the file name.
The substring function extracts the part of the file name that corresponds to the location (for example 'LosAngeles', 'NewYork', 'SanFrancisco'....
The in function will check if the extracted part is within an array containing the list of valid locations.
It will returntrue if the extracted location is in the predefined list, otherwise returns false.
Update :
I thought about using a Switch expression instead of using multiple if conditions.
First, create an array parameter Cities to hold the list of cities you want to work with.
Then, use a ForEach activity to iterate over the cities array, and within that, you can use a Switch expression to create the file name based on the city's name.
"Cities": [
"LosAngeles",
"NewYork",
"SanFrancisco",
// ... 10 more cities
]
// In ForEach activity, iterate over the array
@parameters('Cities')
// Inside the iteration (ForEach activity), use the Switch expression to build the filename
@concat('Payroll_Detail_', item(), '_', formatDateTime(utcNow(),'yyyyMMdd'), '.csv')
the item() function inside the ForEach loop will return the current city being iterated over and be used to construct the filename.
The concat function puts together the required string, including the date in the desired format, resulting in the filenames you provided in your examples.