
Announcements
Hi,
I have two Columns in SharePoint List called Value and Stock.
Result column should be calculated using calculation column logic.
Values and Stock will always have the same number of commas. but there can be any number of commas. So the solution should be smart enough to count number of commas and multiple value in right order.
Please how can I do this in Power Automate and pass it back to Sharepoint List?
Any help is much appreciated. I am new to Power Automate so please try to break it down.
Thanks a lot in advance.
Hi @MiltonK,
I think this is achievable with a couple of supporting variables and split functions.
Below is an example of that approach.
1. Add a initialize variable, call it Count. Set the value to 0.
2. Add a second initialize variable of type integer, call it Result
3. Add a third initialize variable of type Array, call it ValueArray
4. Add a Get Items, Retrieve the Value stock items.
5. Add an apply to each. Use the value in the select an output from previous steps field.
6. Add a Set variable within the Apply to each action. Set the ValueArray variable by using this expression:
split(items('Apply_to_each')?['Value'], ', ')
7. Add a second Apply to each action (calculate results), within the other Apply to each. Use the ValueArray variable for the select an output from previous steps field
8. Add an increment variable action with the second apply to each. Increment the Result variable by using the expression below.
This expression uses a split function to get the separate values and uses the count variable to get the correct item via a variable index. It also a mul to multiply the value with the stock.
mul(int(split(items('Apply_to_each')?['Value'], ', ')[variables('Count')]), int(split(items('Apply_to_each')?['Stock'], ', ')[variables('Count')]))
9. Add a second increment variable action. Increment the Count variable with 1.
10. Place an update item action outside of the second apply to each action, but within the first apply to each action. Update the item with the result variable.
11. Add a set variable action. Reset the Count with 0
12. Add a set variable action. Reset the Result with 0