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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Trying to create a tab...
Power Apps
Unanswered

Trying to create a table column for summing values in Dynamics CRM

(0) ShareShare
ReportReport
Posted on by 118

Hello,

 

I am trying to create a table column for Work Orders that sums a field called "install times" found in dynamics CRM:
43g4.png

 

Each item in the CRM has an install time, and each work order has a list of all items used for it. I simply wish to have a few field that sums the *total* value of all the "install time" in the work order.

 

So I have gone to dataverse>Work Order>Form>New table column>Data Type>Formula. But no matter what I do, I cannot click the "save" button because when I mouse over the many formula(s) I've tried, they all give errors.

1.

 

 

SUM(
 FILTER(
 [WO Product],
 _workorderproductid_value = [_workorderid]
 ),
 installtimetobase
)

 

 


2. 

 

 

Sum(relatedentities('msdyn_workorderproduct', 'msdyn_installationtime'), msdyn_workorderid = ThisItem.msdyn_workorderid)

 

 

 

3. 

 

 

aggregate(
 lookup(
 "workorderproduct",
 "workorder",
 "_workorderid_value",
 [_workorderid],
 "installtimetobase"
 ),
 sum
)

 

 

 

4. 

 

 

_suminstalltimes_value@OData.Community.Display.V1.FormattedValue: (
 select sum(installtimetobase/60) 
 from workorderproduct 
 where _workorderid_value eq [_workorderid]
)

 

----------------------------------------------------------

 

 

 

So I have abandoned that and am now trying to just create a business rule to do it, but I'm a bit confused as to how to accomplish that? 

DVOP_0-1680201726401.png

 

 

I have the same question (0)
  • DevOs Profile Picture
    118 on at

    Is this correct?

    DVOP_0-1680202374541.png

     

  • Anton_Dali_UKR Profile Picture
    75 on at

    You need to crete rollup field.

    In case you want to aggregate calculated value in "parent" record which has 1:N relationship this is exactly what you need. Rollup field settings provide an ability to look into the each related record and summarize - I believe it is yor case - all values from the defined field. 

    The only thing you must be aware of is that this type of field executes operation automatically by schedule. How to impact on this timing is another topic.

  • EricRegnier Profile Picture
    8,720 Most Valuable Professional on at

    Hi @DVOP,

    You won't be able to acheive this with business rules and up-to-now nor with Power FX columns

    You can try rollup columns as @Anton_Dali_UKR suggested but it only gets updated every 12h which might be problematic since it can show stale values to users. There are severals ways to achieve this like with plugins, JavaScript but the easiest way IMO is with Power Automate using the Dataverse connector. Have a cloud flow that triggers when a new item is created/deleted or when the install times is update on the item. Then you can calculate the total install time and update the parent (ie work order).
    Hope this helps!

  • DevOs Profile Picture
    118 on at

    Hello.

     

    Thank you for replying, I did not notice this until now as this has been stressing me so much. I'm not sure if the timing matters as I just need the time values once per work order and maybe like once a week.

     

    But if I were to go the power automate way, how would I do that exactly? When a new item is added to work order entity then...do what? How do I say I want the "install time" field from all products on a work order to be added? 

     

    I'm trying to follow these instructions but they don't match up with the current version of power automate it seems:

    Go to Power Automate and create a new flow.
    
    Choose the "Common Data Service - When a record is created, updated or deleted" trigger and select the "Work Order" entity.
    
    Set the trigger to "When a record is created, updated or deleted".
    
    Click on "New Step" and select the "Common Data Service - List records" action.
    
    Set the "Entity name" to "Product".
    
    In the "Filter Query" field, enter the following query: _productid_value eq '{workorderid}'.
    
    Click on "New Step" and select the "Compose" action.
    
    In the "Inputs" field of the "Compose" action, enter the following expression to calculate the total install time for all products associated with the Work Order: sum(body('List_records')?['value']?['installtimes']).
    
    Click on "New Step" and select the "Common Data Service - Update a record" action.
    
    Set the "Entity name" to "Work Order".
    
    Set the "Record Identifier" to the Work Order ID by clicking on the "Show advanced options" button and selecting "Work Order ID" from the dropdown.
    
    In the "Fields" section, set the "Total Install Time" field to the output of the "Compose" action.

     

  • EricRegnier Profile Picture
    8,720 Most Valuable Professional on at

    Hi @DVOP,

    Yes the Dataverse flow connection and actions have been updated in the last years. Here's an overview of the flow logic:

    1. Flow trigger is When a row is added, modified or deleted , filter on the Work Order table. Change Type of Added, Modified or Deleted since those will impact the install times. Set the Scope to Organization
      EricRegnier_0-1680815321743.png
    2. Get the Work Order details with Get Row By ID action to get the product ID (parent). This is what you want to do the sum by. Pass the ID from the previous step (ie the work order that triggered this flow)
    3. Get all Work Orders related to that product ID with the List Rows action. The filtering syntax might be tricky but ensure you filter by the product ID from step #2.
      EricRegnier_1-1680815605366.png
    4. Initialize a new variable, loop through the rows from step #3 and add the times to the variable
      EricRegnier_2-1680815685522.png
    5. Finally, you need to save the results with the Update a row action

    All the links provided have examples of how to use Power Automate actions. If it's the first time, it may take a bit of time to get familiar and  take a few trials to get things right. Once you're familiar with flows though, you will like it 🙂
    Hope this helps!

  • DevOs Profile Picture
    118 on at

    Hi Eric,

    Thank you for trying to help. I am a bit lost already though as to the whole row ID business, because it'll never be static, it'll be dynamic for each work order generated. Microsoft's instructions that you linked do not explain how to make that dynamic?

    DVOP_0-1680819653142.png

     

  • EricRegnier Profile Picture
    8,720 Most Valuable Professional on at

    Yes you can dynamically get that from the previous step. If you click in the "Row ID" box an itellisense will popup and and pick the unique indentifier from the "When a row is ...." step. Hope this helps!

  • DevOs Profile Picture
    118 on at

    I don't have that 

    DVOP_0-1680822706521.png

     

  • EricRegnier Profile Picture
    8,720 Most Valuable Professional on at

    Yes you almost there! Just pick the column that says "Unique identifier for entity instances"

  • DevOs Profile Picture
    118 on at

    Is this correct?

    DVOP_0-1680831021510.png

    And for step #4, when you say "Initialize a new variable, loop through the rows from step #3 and add the times to the variable". What times are you referring too?

     

    Edit: Shouldn't step 2 table name be "get work order products"? Not "Work orders" again?

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 757 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 322 Super User 2025 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 209 Super User 2025 Season 2

Last 30 days Overall leaderboard