Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Rollup or Calculate this year / last year

Posted on by Microsoft Employee

I see that the date operators in Rollup/Calculate do include this year or last year or anything other than simple inspections.  Has anyone figured out a way to get a sum of invoice detail amount filtered to this year?  To last year?

TIA

  • LuHao Profile Picture
    LuHao 40,872 on at
    RE: Rollup or Calculate this year / last year

    Hi partner,

    In the logic of the Rollup field, the date field can only be compared with another date field or specific value, so we can first create two date fields, one for the start date of this year and the other for the start date of last year, then use Flow to update them every day, and finally use them as the reference date in the logic of the Rollup field.

    The reason for using Flow to update them is that the rollup can only apply filters to the source entity or related entities, simple fields or non-complex calculated fields. (From this document) This is the cause of the error in your second screenshot, the "Age in Years" field is not a non-complex calculated field.

    In addition, could you indicate whether last year is calendar dates (1/1/2019 - 12/31/2019) or natural days (1/6/2019 - 5/30/2020)?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Rollup or Calculate this year / last year

    Thank you.  I know how to write a plugin to aggregate or calculate a field.  However, Microsoft invented Rollup and Calculated fields to spare me the chore of doing that.  My question is pretty clearly about the functionality of Rollup and Calculated fields.

    I will proceed as if the answer is, "no, you can't do that" until someone demonstrates otherwise.  I'm sorry to have taken up your time in making the above presentation and hope it might be of use to someone in the future.

  • LuHao Profile Picture
    LuHao 40,872 on at
    RE: Rollup or Calculate this year / last year

    Hi partner,

    We will create 2 flows, one is to update the exisiting Accounts, the other is to update the Account in real time.

    1. First flow: update exsiting Accounts

    Go to Account view, click Flow > Create a flow.

    pastedimage1590570325675v1.png

    Then set the flow as follow.

    pastedimage1590570391430v2.png

     

    pastedimage1590570405059v3.png

     

    pastedimage1590570421011v4.png

     

    pastedimage1590570438922v5.png

     

    pastedimage1590570453132v6.png

     

    pastedimage1590570464258v7.png

    After saving this flow, return to the Account view of D365 and run this flow.

    In this way, exisiting Accounts will get update based on their Invoices

    After running successfully, this flow can be turned off.

    2. Second flow: update Accounts in real time.

    Create a automated flow as follow.

    pastedimage1590571831097v8.png

     

    pastedimage1590571846322v9.png

     

    pastedimage1590571859352v10.png

     

    pastedimage1590571879372v11.png

     

    pastedimage1590571889118v12.png

     

    pastedimage1590571905438v13.png

    In this way, when the fields "Total Amount", "Customer" and "Date Delivered" are changed, this flow will be triggered to update the Account.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Rollup or Calculate this year / last year

    More than none?  Yes.

    I don't see the similarity between a calculated field and a procedure.  It just seems odd that what I can do for a view/fetchXML is not implemented for the Rollups.  I'm guessing that filter using NOW() on the invoice might have a problem with SQL Server's notion of an indeterminent function.  If the answer is there is no such functionality, then c'est la vie.

    But I need a Rollup field of this year's invoice total and another of last year's on the account form.  I know I can do the math in a webApi fetch but was wondering if there was an easier way.

  • LuHao Profile Picture
    LuHao 40,872 on at
    RE: Rollup or Calculate this year / last year

    Hi partner,

    Do you need more support?

  • LuHao Profile Picture
    LuHao 40,872 on at
    RE: Rollup or Calculate this year / last year

    Hi partner,

    Can you elaborate on your needs?

    If OOTB Rollup or Calculate cannot meet your needs, then we can replace them with Flow.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Rollup or Calculate this year / last year

    I'm trying this as the invoice flag:

    5305.AgeInYears.PNG

    ...and I am getting this denial on the account side:

    3034.IRCY.PNG

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans