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

Announcements

News and Announcements icon
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 Microsoft Employee

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,172 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
    306,731 Super User 2026 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
    Microsoft Employee on at

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

  • Liya Cheng Profile Picture
    Microsoft Employee 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,172 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
    Microsoft Employee 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
    Microsoft Employee 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
    Microsoft Employee on at

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

  • Suggested answer
    nmaenpaa Profile Picture
    101,172 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
    240,312 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288 Super User 2026 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 270 Most Valuable Professional

#3
Anton Venter Profile Picture

Anton Venter 217 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans