cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SamBasso
Helper I
Helper I

Issue with multiplication

Hi All I am trying to multiply two numbers. One number is from list when item is created or updated. The second is sourced from get items actions. I am trying to perform the calculation in a Compose action (realise this may be wrong approach - I am still new to Power Automate).

 

I received this error: Unable to process template language expressions in action 'Compose' inputs at line '1' and column '12206': 'The template language function 'mul' expects its second parameter to be an integer or a decimal number. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#div for usage details.'.

 

This is the calculation in Compose: mul(triggerOutputs()?['body/Price'],outputs('Get_items')?['body/Referral Fee'])

The issue is with the Get_Items syntax as if I replace it with a value of say 2, the flow works. Both columns have are of type Number - but the column from Get_Items is shown as a percentage to 0dp.

 

Attaching images below. If anyone could help I would appreciate it, thanks. 55.PNG56.PNG

 

55.PNG56.PNG

1 ACCEPTED SOLUTION

Accepted Solutions

@SamBasso   some columns in the array are null. 

 

Your sintax is correct, but when the expression try to calculate your second parameter that is your get items and contents some null values in the array you have this error.

 

You can try adding a condition to compare just the values that are not null.. and try adding a data type like int to your mul parameters like this.

 

mul(int(triggerOutputs()?['body/Price']),int(outputs('Get_items')?['body/Referral Fee']))

 

see the suggestion is in bold. 😉



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA

View solution in original post

8 REPLIES 8
ChristianAbata
Super User II
Super User II

hi @SamBasso  this is because in some values when you use get value some of that are empty or null

 

 



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA
SamBasso
Helper I
Helper I

Thanks Christian.  Are you saying the filter query doesn't return any items or that some columns in the array are null? 

 

I am hoping that the code for get_items gets the specific column but not sure if it's correct syntax.

mul(triggerOutputs()?['body/Price'],outputs('Get_items')?['body/Referral Fee'])

 

Thanks

Sam

 

@SamBasso   some columns in the array are null. 

 

Your sintax is correct, but when the expression try to calculate your second parameter that is your get items and contents some null values in the array you have this error.

 

You can try adding a condition to compare just the values that are not null.. and try adding a data type like int to your mul parameters like this.

 

mul(int(triggerOutputs()?['body/Price']),int(outputs('Get_items')?['body/Referral Fee']))

 

see the suggestion is in bold. 😉



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA

View solution in original post

Thanks Christian.

 

Ok understood that the issue is because some items in the array are NULL.  I created a second list with only two columns but have the same issue (maybe the hidden columns/metadata are null?).

 

Not sure how to 'try adding a condition to compare just the values that are not null'.

 

Told you I was a beginner 🙄

hi @SamBasso mmm it's diffcult to helps because I needed your same dta but, see an example about how you can avoid null values

 

nullequals.PNG

 

as you see everything is null, is going to be true, and false are going to content just allowed values to multiply



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA

Hi Christian

 

I think I solved the issue by adding some variables.  So now I set the Commission Rate variable as;

add(mul(variables('Price'),variables('CommissionRate')),0.00001)
Note: I added 0.00001 to the expression as sometimes the price x commission rate could return value with one decimal i.e. 5.5.
(The valuable should have 2dp so not sure about using int)
 
Next I made a compose action using the Commission Fee variable was used in updating the list (did not seem possible to consolidate this expression into the Set Variable action):
substring(string(variables('CommissionFee')),0,add(indexof(string(variables('CommissionFee')),'.'),3))
 
The flow seems to be working but intermittently - but I think it seems to be triggering an update to another item in the list.
 
Because the trigger is 'when an item is created or modified'  - I think there is an infinite loop also.  I have read plenty of resources on that.  Doesn't seem that I can overcome the issue in the Trigger Conditions (settings) as it's not possible to refer to a variable (I just want the flow to run if it's a new item or the Commission Fee of the modified item <> the Commission Fee set previously).  I have tried to overcome this with a condition prior to the update action:
outputs('Compose') is not equal to trigger(Outputs()?[body/CommissionFee']
 
I've noticed that the flows are taking a while to trigger also (created a new item an hour ago and the flow has not triggered). So this is still very much a work in progress.  Really stuck around the loops now but I am not sure why the flow seems to be updating more than one item in the target list.
 
Can share code but if something jumps out to anyone would appreciate some constructive thoughts.
 
Thanks
 
Sam

@SamBasso  excellent, please try to mark an answer to solution to guide others 😉 be free to leave some kudos too 



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA

Thanks for the input and steer.  I will most likely create a new thread as there are still some issues around the infinite loop and possibly a glitch with this flow (and the design of the flow has moved on since this thread was started). 

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Users online (54,769)