web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Calculate multiple Fields using workflow

(0) ShareShare
ReportReport
Posted on by

How does one calculate multiple fields using more than two fields so that the sum will be in another field?

Performing a calculation for two fields is simple enough, but I'm having difficulty in trying to setup a workflow to add multiple fields (7 in total) together.

I'd rather not have to use JScript to accomplish this.

I have several fields that need to total into one field, for example, 1 field +1 Field +1 Field= Sum of Fields

If anyone can point me in the right direction, it would be greatly appreciated.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Aileen Gusni Profile Picture
    44,524 on at

    Hi Michael,

    I have same requirement with you, for example :

    1614.Business-Rules-Calculate-Multiple-Field-1.png

    To count the Total Food Claim, I have to calculate Breakfast, Lunch, and Dinner Expense, and also Snack Expense.

    Means that Total Food Claim = Sum of (Breakfast Expense + Lunch Expense + Dinner Expense + Snack Expense).

    Business Rules in CRM 2013 basically only can afford for simple calculation, 2 fields only as formula set field value.

    So, it can be tricky, but it is possible!

    To achieve this without JavaScript, but using Workflow or Business Rules, you have to set the value gradually, step by step, and using multiple business rules for each condition.

    Here is the guide.

    1. Create first Business Rules with Field1 is contain data, in my case : Breakfast Expense :

    3531.Business-Rules-Calculate-Multiple-Field-2.png

    2. Do it until your first Business Rules will become this :

    Put your formula of calculation in Action gradually for each field

    0310.Business-Rules-Calculate-Multiple-Field-1-Contrast.png

    3. Create a new Business Rules based on this Business Rules as Template, utilize the Save As Button, now in this time attach to the contradict Condition :

    1665.Business-Rules-Calculate-Multiple-Field-4.png

    Because Business is currently not supporting If Else Statement, and you want to calculate your fields, even though one of the field is not containing any data.

    4. Repeat for your other fields, for Field2, Field3, etc. In my case : Lunch Expense, Dinner Expense, Snack Expense.

    2538.Business-Rules-Calculate-Multiple-All.png

    5. So finally, you will have 8 Business Rules, depends on your Total Fields, if you have 7 fields, then you might need 14 Business Rules.

    0636.Business-Rules-Calculate-Multiple-Field-Result.png

    6. Don't forget to activate all of them and then test them :

    Fill in the fields

    2068.Business-Rules-Calculate-Multiple-Field-Result-On-Change.png

    6170.Business-Rules-Calculate-Multiple-Field-Result-No-Dinner.png

    If no dinner (zero value or no data of dinner expense)

    Hope it helps!

  • Aileen Gusni Profile Picture
    44,524 on at

    Hi Michael,

    I give you example to use Business Rules because before that you told us that you'd rather not to use Javascript.

    Yes, Javascript is easy to maintain as well, you can make your javascript dynamics as well using the parameter in the form, so don't hard code the field name :)

    Your verified answer is means a lot :)

    What Guido says is right if you know Javascript then use it because you dont have to deactivate and activate it again.

    Thanks.

  • mcw1882 Profile Picture
    on at

    I don't know Javascript. I have been trying to avoid because I have read that the script can become broken by certain updates. Can either of you recommend a good book to pick up regarding Javascript, or a good site?

  • mcw1882 Profile Picture
    on at

    Thanks for that. Pretty much what I was afraid of. Seems that basic math for multiple fields shouldn't be as difficult to do.

  • Aileen Gusni Profile Picture
    44,524 on at

    Hi Michael,

    Then using the Business Rules like I suggested before, I also suggest the same thing to my friend that does not need to care about Javascript. Hopefully you can enjoy it!

    Thanks!

  • Tim Dailey Profile Picture
    440 on at

    Hi Aileen,

    Is this easier now with 2015 and enhanced else/if added to business rules?

    I have about 12 fields I want to add up to get a total.  Sometimes they will not all be populated with a value, but I still need the calculation to work. Thank you for any help you can give me!

    Tim

  • Daniel at VNS Profile Picture
    on at

    This is good.  But what to do if you are working with Service Activity entity, which has no support for Business Rules - even in CRM 2016.  I'm trying to add multiple whole number duration fields and also could not find a way to make this work in WF.  

    ie: If I have 4 fields that are 1 hour, 15 minutes, 2.5 hours and 3 hours, I am trying to create a field that says 6.75 hours.....without JS.  

    Thank you.

  • Suggested answer
    PS Profile Picture
    23,577 on at

    Hi Daniel,

    Create a calculated field 'Total Duration' = Duration 1 +Duration 2 +Duration 3 + Duration 4

    3175.1.PNG

    3175.1.PNG

    And it will calculate all of them, like this:

    6708.3.PNG

    Hope this is what you are looking for !

    Similar answer here: https://community.dynamics.com/crm/f/117/t/216610

  • Daniel at VNS Profile Picture
    on at

    Thank you Prashant.  So that was my initial response, but I found none of the Billable (simple whole number) fields even appears as an option in the calculated list to *be* selected.  I tried re-creating the Total Billable time field different ways - as a whole number, as a decimal.  Still no luck - none of the existing Billable Time duration fields would appear as choices in the Calculated fields form.   I also tried workflow - same results.

    Any ideas on why I cannot select them would be appreciated.

    Thank you

    11_2D00_14_2D00_2016-8_2D00_29_2D00_32-AM.gif 11_2D00_14_2D00_2016-8_2D00_29_2D00_32-AM.gif

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans