I don't like looping over table rows and using variables:

Compose: Some sample data
[
{"Name": "Jim", "Status": "DUTY"},
{"Name": "John", "Status": "WFH"},
{"Name": "Jane", "Status": "RD"},
{"Name": "Jenny", "Status": "DUTY"}
]
Apply to each Status: Loop over an array with all statuses
["DUTY", "WFH", "RD"]
StatusPerson: Compose action to get the names per status and format it to text
concat(
items('Apply_to_each_Status'),
decodeUriComponent('%0A'),
join(
xpath(
xml(json(concat('{"root":{"person":', outputs('Compose'),'}}'))),
concat('//person[Status="',
items('Apply_to_each_Status'),
'"]/Name/text()')
),
decodeUriComponent('%0A')
)
)
Here you have to adapt outputs('Compose') to your data array.
Message: Compose action to combine all StatusPersons
join(
outputs('StatusPersons'),
concat(
decodeUriComponent('%0A'),
decodeUriComponent('%0A')
)
)
Outputs:
DUTY
Jim
Jenny
WFH
John
RD
Jane