Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

Power automate flow - multiple compose or initialize variables & sum



I'm trying to improve a manual process where i am collecting data (6 questions) and based on the replies calculating a value and replying to each visitor.

Each time a visitor fills in the questions i am receiving an email notification with the details and i'm pasting them in a Sharepoint list with the following:

Name                surname               email                 answer 1              answer 2           answer 3            answer 4             answer 5

 John                    Doe         Answ 1 - 1          Answ 2 - 2          Answ 3 - 3          Answ 4 - 4     Answ 5 - 5


The answers have a point value at the end in the form of "Answer 1 - 1".

I've been trying to set up a flow that would trigger when a new line is created in the sharepoint list and, select left 1 character for each answer and then initialize it as a variable, integer and calculate the sum of all answers.

As i've not been able to get this to work i discovered that i could use compose in the following fashin:

Compose - Answer 1 - 1

and then use

substring(outputs('compose'), sub(length(outputs('compose)), 2),2)
that would allow me to do the left selection and get the 1 point for the answer but, when i tried to scale it and add a second compose i could not get the flow to work, it was returning :
"correct to include a valid reference to 'compose 2'".
I've also tried initializing the answers as integers but i do not know how to do the left selection in order to have a variable with a value of 1-5 that i could then sum.
Please let me know if i'm making any sense or if it would work better to add pictures of the flow i'm trying to set up, thanks in advance !
Kind regards,



Accepted Solutions
Resolver I
Resolver I

Hi @mihaim44 


Try intialize variable type as string 


It will work around 



View solution in original post

Resolver I
Resolver I

Hi @mihaim44 

are u still confused on how to take the last value (ie the points)

Resolver I
Resolver I

Hi @mihaim44 

You can try the split operation here as well to extract the points

For eg your data is Ans - 1


Then use this split expression 


int(split('Answer 1 - 1','-')?[1])   , (please note that i had directly hardcoded the value instead of passing as variable for a demo)
The output i got is


Try this way around


Mark it as solution if it helps



Nived N

Frequent Visitor

Hi Nived,


I'm not sure i understand.

As an example, this is how the flow is currently configured : 


current flow.png


The answer values are the ones called "Intrebare x Value" and they contain values from "Text - 1" to "Text - 6".

As in the sharepoint list - Intrebare x Value is a drop down menu with the following options:

"Text - 1"

"Text - 2"


"Text - 6"

The compose i used extracted the last value but i do not understand how to use the formula you gave.

Should i add it into a compose with the expression:

int(split('Intrebare x Value','-')?[1]) ? 

i tried the above in a compose but i only get it to send the result.pngvalue or fail.


I apologize for being dense, my coding experience is extremely limited to say the least.

Thanks in advance !

Kind regards,


Hi @mihaim44 

I showed a simple example to show you the idea 


Here i created a sample flow





First i intilazed a variable a1 with value Answer 1- 1


Then in compose action next to it, i used the following expression to extract the 1 from that a1 (ie the point)



This is how i extracted for one data ie a1 variable


Simmilar way u can try for others too

Hi Nived,


I've tried the following:

test v2.png

When the SP list is updated the flow picks up the value from the row (text) then tries to initialize it as "V1" as int and then compose with : split(variables('V1'),'-')?[1]

But it returns :

The variable 'V1' of type 'Integer' cannot be initialized or updated with value of type 'String'. The variable 'V1' only supports values of types 'Integer'.


Is this due to the fact that the row it reads from is declared as test / string ?

Should i do a compose before the initialize in order to convert "Intrebare 1 value" to Int, then initialize and compose in order to extract the last number ?


Kind regards,


Resolver I
Resolver I

Hi @mihaim44 


Try intialize variable type as string 


It will work around 



Frequent Visitor

Thank you very much !


Worked like a charm ! 


Kind regards !


Helpful resources

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power automate tips 768x460 v2.png

Restore a Deleted Flow

Did you know that you could restore a deleted flow? Check out this helpful article.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Users online (3,164)