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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

multiple table query grouping

(0) ShareShare
ReportReport
Posted on by

Hello,

I have an issue. There is a query made of inventTrans and inventDim tables. I need to group by one of InventTrans and a few of InventDim fields. Query works fine, when I add invTransDS.addGroupByField(fieldnum(InventTrans, ItemId)) it groups by itemId from inventTrans, but other fields from inventDim becomes null in grouped record. How could I solve this? Thank you.

*This post is locked for comments

I have the same question (0)
  • Zain Bokhari Profile Picture
    3,208 Moderator on at
    RE: multiple table query grouping

    This should bring all three values if they exist. Pick one item number and Cross check with your data, you can also iterate through this query in a job. You will see the results.

  • Verified answer
    Vilmos Kintera Profile Picture
    46,149 on at
    RE: multiple table query grouping

    How does the query look like in pseudo-SQL if you do itrDS.toString() call before the queryRun object?

    Maybe you should include the relation field InventDimId.

  • Community Member Profile Picture
    on at
    RE: multiple table query grouping

    8270.Untitled.png

  • Zain Bokhari Profile Picture
    3,208 Moderator on at
    RE: multiple table query grouping

    Can you show us your query? with all groups ?

  • Community Member Profile Picture
    on at
    RE: multiple table query grouping

    It groups correctly, it just doesn't show the value.

  • Community Member Profile Picture
    on at
    RE: multiple table query grouping

    Its non-numeric, but I group by this field and it shows no value.

  • Zain Bokhari Profile Picture
    3,208 Moderator on at
    RE: multiple table query grouping

    If that field is a text field it will definitely not have a value. Like I said, non-numeric non-grouped fields are left blank when a grouping is added to the query.

  • Community Member Profile Picture
    on at
    RE: multiple table query grouping

    I use this query in a form. When I group by two fields, it groups well (the amount of rows is correct), but one field still doesn't have value.

  • Verified answer
    Zain Bokhari Profile Picture
    3,208 Moderator on at
    RE: multiple table query grouping

    You can only get the grouped data from multiple fields, if you group by multiple fields.

    For example if a table has three fields A, B, C and you group by A, you will only get the value for A. The other fields, if non-numeric, will be blank.

    If you want results for all of these fields you can add all of these as group by fields on the datasource. Which will give you combinational groups of fields.

    ( A-value1 B-value1 C-value1 )

    ( A-value1 B-value1 C-value2 )

    ( A-value1 B-value2 C-value1 )

    ( A-value1 B-value2 C-value2 )

    and so on ..

    You get the idea.

    Where do you want to use this query btw? Report? Because if so, you can do the grouping at report end as well.

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at
    RE: multiple table query grouping

    I am unsure what exactly do you mean, but you need to group by on all datasources on all fields that you expect to return. Here is an example:

    axatluegisdorf.blogspot.hu/.../select-group-by-and-join-order-by.html

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Syed Haris Shah Profile Picture

Syed Haris Shah 9

#2
Mea_ Profile Picture

Mea_ 4

#3
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans