How do I build a string from all items in a row depending on the application of a criterion to another row?

I’m looking for, or looking to construct something that will work a bit like SUMIF, something that will apply a criterion to a range in row 2 and, where they match the criterion, do something with cells in that column in row 1.

But instead of having the matching items in row 1 treated as numbers and summed, I want them treated as strings and concatenated.

Illustration:

I have a table showing project numbers (one per column), and subcontractors (one per row):

|   | A       |     B |     C |     D |     E |
| 1 |         | 23001 | 23002 | 23003 | 23004 |
| 2 | Ashley  |       |       |       |       |
| 3 | Blair   |       |       |       |       |
| 4 | Charlie |       |       |       |       |

When a subcontractor submits an invoice, its amount is entered in the column for the project it relates to:

|   | A       |     B |     C |     D |     E |
| 1 |         | 23001 | 23002 | 23003 | 23004 |
| 2 | Ashley  | 20.50 |       |       | 95.00 |
| 3 | Blair   |       | 34.22 |       | 47.00 |
| 4 | Charlie | 72.00 |       | 21.00 |       |

Now, for each subcontractor, I’d like to construct a string listing all the projects for which they’ve submitted an invoice, so “23001 23004” for Ashley, “23002 23004” for Blair, etc.

Is there a way to construct a formula that scans through Ashley’s row, for example, and collects all the project numbers that correspond to all the cells in that row that contain a value > 0?

If it made things easier, it would be possible to swap the axes along which the data is laid out, i.e. to have each project in a row and each contractor in a columns.

This is the table layout which makes everything much easier:

Article Client Value
23001 Ashley 20,5
23004 Ashley 95
23002 Blair 34,22
23004 Blair 47
23001 Charlie 72
23003 Charlie 21
2 Likes

LibO Calc version 4.4 or higher.

For Ashley (in F2, e.g.):
=TEXTJOIN(";" ; "1"; IF($B2:$E2="";"";$A$1:$E$1))
Then fill down as needed.
Because the subexpression IF($B2:$E2="";"";$A$1:$E$1) requires “iterative” array-evaluation, you need to enter the given formula with the Ctrl+Shift+Enter combo. FillDown by dragging the fill handle with the mouse requires an additional Ctrl+ too.

Next time attach an example sheet as .ods.

Thanks very much, Lupp. Your example show me several things I didn’t know before. I appreciate it!