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)

How i can group(sum) in a view???

(0) ShareShare
ReportReport
Posted on by 578

Hi

I need group quantities in a view.

6428.q1.PNG

Actually return...

1-01-54-000-00002-92 | P135177 | 22050.0000000000000000

I like return ...

1-01-54-000-00002-92 | P135177 | 44100.0000000000000000

In code i have...

this.query().dataSourceName(this.name()).fields().addField(fieldnum(BomTable, BOMQty), SelectionField::Sum);

You can help me...

Thanks

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    Either you can use groupby on your underlying query or with a help of computed column on your view.

    Refer following links:

    (Walkthrough: Creating an AOT Query that has Group By and Having Nodes [AX 2012])

    msdn.microsoft.com/.../hh745337.aspx

    (Computed View Columns in AX 2012)

    daxmusings.codecrib.com/.../computed-view-columns-in-ax-2012.html

    (View Basics [AX 2012])

    msdn.microsoft.com/.../bb314551.aspx

  • Verified answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    You can try the following code:

     QueryBuildDataSource    qbdsProd, qbdsBOM;
    
        qbdsProd = this.query().datasourceTable(tablenum(ProdBom));
        qbdsBOM = this.query().datasourceTable(tablenum(BOMTable));
    
        qbdsProd.addGroupByField(fieldNum(ProdBOm, ItemId)); // Assuming you have ProdBOM table
        qbdsProd.addGroupByField(fieldNum(ProdBOm, ProdId));
        qbdsBOM.addSelectionField(fieldNum(BomTable, BOMQty), SelectionField::Sum);
    
        


  • ismaelivan Profile Picture
    578 on at

    Success!!! this line was the solution...

    qbdsBOM.addSelectionField(fieldNum(BomTable, BOMQty), SelectionField::Sum);

    instead of

    this.query().dataSourceName(this.name()).fields().addField(fieldnum(BomTable, BOMQty), SelectionField::Sum);

    Thank very much

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