Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

Max of Two Aggregation Fields in D365 View.

(0) ShareShare
ReportReport
Posted on by 65

Hi Everyone,

I want to get the Max of Field of two Aggregate Fields in my View. I am trying to do it through computed column but can't figure out the way to get the Max Aggregate Fields of my view in the View Method. So, I have two questions:

How to reference the Aggregate View Fields in View Method?
What's the best way to get the Max of two View Aggregate Fields other than View Method?

Note: View's query already has a Group By.

Thanks.

  • OsamaAG Profile Picture
    OsamaAG 65 on at
    RE: Max of Two Aggregation Fields in D365 View.

    Thanks goshoom .

    Yes, I was writing SQL before I started implementing in X++, what I was trying to do was to reference the Already Aggregated fields of the views but your method also works in my case.

    Thanks again.

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,934 Most Valuable Professional on at
    RE: Max of Two Aggregation Fields in D365 View.

    A computed column method is a method generating a piece of T-SQL code. Therefore you need to decide what SQL code you want to generate before you start writing X code for it. Have you done that?

    The easiest way would be using GREATEST() function, but while it should work in Azure SQL, you would have a problem in Tier1 environments, if they aren't on SQL Server 2022.

    What you could do instead is using select from values. For example:

    (select max(n) from (values (max(num1)), (max(Num2))) as t(n))

    Use the example to prepare SQL for your particular situation and test it before writing X code for it,

  • OsamaAG Profile Picture
    OsamaAG 65 on at
    RE: Max of Two Aggregation Fields in D365 View.

    goshoom can you help me with this please.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,111 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,934 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans