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 :
Finance | Project Operations, Human Resources, ...
Answered

x++: how can i get the maxValue and minValue of real and decomal by using code in Dy365F&O?

(0) ShareShare
ReportReport
Posted on by

Description:

i want get the max value and min value of decimal by X++  code? but i didn't know how can i  write it, if you know , please tell me ,thanks!

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    select minOf(MyField) from myTable;
    info(strFmt("Min value: %1", myTable.MyField));
    
    select maxOf(MyField) from myTable;
    info(strFmt("Max value: %1", myTable.MyField));

  • André Arnaud de Calavon Profile Picture
    300,911 Super User 2025 Season 2 on at

    Hi Apple,

    Can you explain if you want to know the min and max for table values used or the data type itself? If it is about used values, then the reply from Nikolaos should be your answer.

  • Suggested answer
    Luke Sha Profile Picture
    on at

    please refer global class, you can find datemax(), realmax(), intmax(),  etc.

  • Liya Cheng Profile Picture
    on at

    This method couldn't return the max value or min value of decimal, because , i get  a error (Microsoft.Dynamics.Ax.Xpp.ClrErrorException: OverflowException ---> System.OverflowException: Value was either too large or too small for a Decimal.), but i don't know the max value and min value of decimal in ax, so i want to know their value

  • nmaenpaa Profile Picture
    101,160 Moderator on at

    Do you still have some open questions or is your original issue now resolved? If it's now resolved, please mark the helpful answer(s) as verified. Thanks!

  • Liya Cheng Profile Picture
    on at

    i want to know the max value and min value of decimal data type itself, because i get a error about decimal (error:Actual: Value was either too large or too small for a Decimal ), but i don't know the size of it, so please tell me if you know, thanks!

  • Liya Cheng Profile Picture
    on at

    No , the issue doesn't resolved yet, your method couldn't address my issue. so i need continue to ask, thanks!

  • Liya Cheng Profile Picture
    on at

    i check the Global class, but nothing about the value of decimal

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    What do you mean by "decimal"? You can find the max/min value of "real" data type in Global class (realMax() and realMin() methods). Decimals are handled as real data type in x++.

    Can you share your code? Where is the "bad" value coming from? Please tell us more about your situation.

  • Suggested answer
    Martin Dráb Profile Picture
    237,803 Most Valuable Professional on at

    Decimal is a CLR type, not an X++ type, therefore simply look into .NET documentation: Decimal Struct. It says:

    The Decimal value type represents decimal numbers ranging from positive 79,228,162,514,264,337,593,543,950,335 to negative 79,228,162,514,264,337,593,543,950,335.

    If you need a check in code, use its properties called MinValue and MaxValue.

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans