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 AX (Archived)

Math equation solver

(1) ShareShare
ReportReport
Posted on by 3,542

I am working on functionality that allows the user to perform calculations on given datasets, constants and variables. For example, one of the datasets I supply is the revenue a single worker is responsible for - the user can specify the time frame.

So then you could have an equation

some total = MAX(A) + SUM(A) + B/C - (F-D) where

A = some dataset

B,C,F,D = some total already calculated and now referenced or some constant

Now I just Rambo'd in and started writing a class called PeteAlbertsEquationSolverWorldSolution, which I enjoyed very much. But then reality hit - my boss reminded me that in the real world we have time constraints. So now I'm looking for some existing functionality to use. (Which I should've done from the start.)

Could someone direct me somewhere?

*This post is locked for comments

I have the same question (0)
  • Pete Alberts Profile Picture
    3,542 on at

    (The 'some total' expression isn't meant to make any sort of sense, its just for illustrative purposes.)

    For some reason it happens a lot that just when you ask a question you find a solution. ---- I have come across the class ProdMathEvaluator that uses Microsoft.Dynamics.Ax.Frameworks.Controls.ProductConfiguration.MathEvaluator::Evaluate(str)

    But it's quite straight forward - it looks like you supply a string with reals and normal math operators.... I am quite sure I''l have to let the user know where his equation went wrong....which is definitely going to happen.

    In any case, I'll try this one. Please let met know if someone has an alternative or better solution

  • Mea_ Profile Picture
    60,284 on at

    You missed one important thing, you did not explain the scenario. Because if you are talking about reporting D365FO has electronic reporting functionally that is literally a platform inside of a platform. You can easily find documents describing math operations over different data sources on docs. But it's more than that.

  • Pete Alberts Profile Picture
    3,542 on at

    It's not for reporting. We are working on a commission add-on. For example you can have a monthly commission correction. If the worker earned x commission in a specific month, but the policy states that (because of some complex calculations), the allowable commission is only x-100. Then the worker's commission for the month needs to be adjusted by 100 bucks and a lot of other accounting corrections.

  • Pete Alberts Profile Picture
    3,542 on at

    So it's meant for a class. Code in a D365 class. Not reporting.

  • Grzegorz Skrzypczyk Profile Picture
    225 on at

    In some of the older versions of AX I have come across functionality where X++ source code was placed in a database field and then compiled and executed at runtime. The place which comes to mind in the standard version of AX would be Product Builder, presumably prior to AX2012. You might want to look at this. Bear in mind that it is an enormous security risk and you would need to ensure the use doesn't intentionally or accidentally inject code with dangerous side effects.

    Grzegorz

  • guk1964 Profile Picture
    10,888 on at

    There are many places where calculations are done e.g. payroll, mrp, bom costing sheet,

    I assume you are familiar with this link https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/dev-ref/xpp-math-run-time-functions

    You can see a simple example here http://axtricks.blogspot.com/2015/01/ax-2012-how-to-evaluate-mathematical.html

    There is also a formula builder in the India tax localization.

    You will find it useful to read up on collection classes.

    Also refer to the Inside Dynamics Ax book.

  • PA-22040759-0 Profile Picture
    6,194 on at

    Assuming you are on D365, I'm afraid that Grzegorz Skrzypczyk's is not possible anymore. You can't compile anything on the fly.

  • Pete Alberts Profile Picture
    3,542 on at

    Thank you all.

    Magic1949 I am looking for that "India tax localisation" example. Any directions? Also, the second link you provided uses XppCompiler. Are there any significant differences to Microsoft.Dynamics.Ax.Frameworks.Controls.ProductConfiguration.MathEvaluator::Evaluate(str) ? I used the later in code already. So I'd like to be sure what I'm replacing and https://msdn.microsoft.com/en-us/library/xppcompiler.execute.aspx doesn't really give any details.

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 AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans