
Compose (a list of file names)
[
"XYZ_010124.xlsx",
"XYZ_200124.xlsx",
"XYZ_210124.xlsx",
"XYZ1_290124.xlsx",
"XYZ2_290124.xlsx",
"XYZ_130124.xlsx",
"XYZ_020124.xlsx",
"XYZ_010124.xlsx",
"XYZ_010224.xlsx",
"XYZ_200324.xlsx",
"XYZ_200324.xlsx",
"XYZ_290324.xlsx",
"XYZ_130324.xlsx",
"XYZ_310324.xlsx",
"XYZ_200324.xlsx",
"XYZ_300324.xlsx",
"XYZ_240524.xlsx"
]
Select (adds properties for filtering and sorting)
From
outputs('Compose')
Map Name
item()
Map dd
take(last(split(item(), '_')), 2)
Map MMyy
take(skip(last(split(item(), '_')), 2), 4)
Map Date
concat(
'20',
take(skip(last(split(item(), '_')), 4), 2),
'-',
take(skip(last(split(item(), '_')), 2), 2),
'-',
take(last(split(item(), '_')), 2)
)
Filter array (filters for less or equal today minus 14 days)
From
body('Select')
Filter
item()['Date']
is less or equal to
addDays(utcNow(), -14, 'yyyy-MM-dd')
Select 2 (finds the last date per month)
From (array of distinct months from property MMyy)
union(
xpath(
xml(json(concat('{"Root":{"Item":', body('Filter_array'), '}}'))),
'//MMyy/text()'
),
json('[]')
)
Map (finds the biggest dd of the current MMyy)
xpath(
xml(json(concat('{"Root":{"Item":', body('Filter_array'), '}}'))),
concat('//Item[MMyy ="', item(), '" and not(./dd < ../Item[MMyy ="', item(), '"]/dd)]/Name/text()')
)
Compose 2 (flatens the nested arrays from Select 2)
first(json(replace(string(body('Select_2')), '],[', ',')))
