Apologies if this has been asked before, but I can't seem to find the answer online, although I may just be searching for the wrong things.
TL;DR: How do you input expressions into the variables() function, for example in loops where the variable needed changes on each iteration?
Due to the way my business is run, we need to keep track of time spent on each client who we work for and I'm trying to create a flow to automate this process. The time tracker data for the last week is put into an excel table of which the flow performs an 'Apply to each' process and for each time log matching a client 'x' it increments 2 variables "'x' Hours! and "'x' Minutes" by the hours/minutes value in the time log, where 'x' is a client's name. The aim of this is to then add rows to another excel table with columns named "Client", "Hours" and "Minutes" so we can see the total time spent on each client for that week. Hopefully I've explained my process so far clear enough for people to understand.
Unfortunately we have quite a large list of clients and so adding an 'Add row to an excel table' action for each one would not only be quite tedious and make my flow overly long but would be prone to errors and would it make it difficult to add or remove clients. Therefore, I decided to make an array of clients and have an Apply to each loop run through it adding a row to an excel table each time adding the client name with their respective hours and minutes. However, if I try to add a variable using an expression so that the variable name changes on each loop, and so I get a different variable on each loop, I'm not allowed to save my flow. This is due to the variable() function not accepting anything but a string as a parameter even if the parameter I'm providing (e.g. items('Apply_to_each')['Hours'] or item().Hours or concat(items('Apply_to_each'),' Hours') ) evaluates to a string.
I can't really attach a screenshot of my flow as it has a lot of client names so hopefully my explanation is all that is needed.
Does anyone know why the variables() function won't accept other expressions and does anyone know a workaround for what I'm trying to do?
Thanks in advance for any help anyone can provide.
Kyle