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)

X++ AOT Query Aggregate 'Having' Value Property Equal to Another Field

(0) ShareShare
ReportReport
Posted on by 5

I'm trying to create an AOT Query replicating an SQL query where the Sum of one column is not equal to the value of another.  Can anyone help me understand the syntax for adding this in the Value property of the 'Having' node?

(in SQL)
having sum(tableB.receiveNow) != TableA.receiveNow

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    As far as I remember the value field could only contain constants, you cannot refer values within the query.

  • Kanoa Profile Picture
    5 on at

    Thanks for responding, are you aware of a way to add the "Having" value in code?

  • Kanoa Profile Picture
    5 on at

    Thanks for your reply.

    I'm using an AOT query to get an initial data set for a report. I can easily do this using SQL, or x++ SQL however the business has asked for dynamic query parameters in the dialog so this needs to use an aggregate query object where the sum or one column is not equal to the value of another.  (sum(vendInvoiceInfoSubLine.receiveNow) != vendInvoiceInforLine.receiveNow) for qty mismatch.

    What I'm looking for is a way to add that to a Query object either in the aot or at run-time.

  • Kanoa Profile Picture
    5 on at

    Is there a way to join table A to the view where the quantities are not equal?

  • Kanoa Profile Picture
    5 on at

    Or are you saying that's not possible and I HAVE to create a subset in the form of a view in order to get this functionality.

  • Kanoa Profile Picture
    5 on at

    Thanks for your help, this did work.

    I created the view that included the receiveNow field from the line and the SUM(receiveNow) from the subLine and joined that to my original query. Then I was able to add a query range at run-time using:

    qbr2 = qbds2.addRange(fieldNum(myView, SumOfReceiveNow));

    qbr2.value(strFmt('(%1.%2 != %1.%3)', tableStr(myView),fieldStr(MyView, receiveNow),  fieldStr(MyView, SumOfReceiveNow)));

    Thanks again.

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