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 NAV (Archived)

SUM Calculations with FILTER is NOT showing correctly

(0) ShareShare
ReportReport
Posted on by

Hi All,

I'm fairly new with NAV Coding. Can you please tell me what I'm doing wrong:

I want to calculate the SUM of quantities in "Item Ledger Entry" filtered by the Users "Shortcut Dimension 1 Code".

In the Item Table fields are:
- "Global Dimension 1 Filter"
       FieldClass = FlowFilter
       TableRelation = "Dimension Value".Code WHERE (Global Dimension No.=CONST(1))
- "InvQty" (for getting the sum of quantity)
        FieldClass = FlowField
        CalcFormula(Sum("Item Ledger Entry".Quantity WHERE (Item No.=FIELD(No.),Global Dimension 1 Code=FIELD(Global Dimension 1 Filter)))

In the List Page I did this
- OnOpenPage
IF UserSetup.GET(USERID) THEN
VALIDATE("Global Dimension 1 Filter",UserSetup."Shortcut Dimension 1 Code");
MESSAGE('%1',"Global Dimension 1 Filter"); -- Just for checking if getting the correct data

 I'm getting the total of all quantity and not filtered by "Shortcut Dimension 1 Code".

Please help

Thanks.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Saurav.Dhyani Profile Picture
    14,380 Super User 2025 Season 2 on at

    If i am not wrong you have these two as custom fields -

    > User setup - Shortcut Dimension 1 Code).

    > Item - InvQty.

    Try This -

    IF UserSetup.GET(USERID) THEN 

    Item.SetFilter("Global Dimension 1 Filter",UserSetup."Shortcut Dimension 1 Code");

    Item.Caclfields( InvQty);

    Let us know how it goes.

  • Community Member Profile Picture
    on at

    Hi Saurav,

    I did what you suggest. I added Item table to C/AL Globals.

    IF UserSetup.GET(USERID) THEN

       Item.SETFILTER("Global Dimension 1 Filter",UserSetup."Shortcut Dimension 1 Code");

       MESSAGE('%1',Item."Global Dimension 1 Filter");

       Item.CALCFIELDS( InvQty);

    On page loading the message is blank. It's not picking up the UserSetup."Shortcut Dimension 1 Code". I also changed it to SETRANGE but same result.

    When I click the InvQty the "Item Ledger Entry" shows that it is only filtered by "Item No." no other filter.

    Thanks.

  • Suggested answer
    Ashwini Tripathi Profile Picture
    4,624 on at

    On OpenPage trigger you need to write code similar to this:

    usersetup.GET(USERID);

    IF usersetup."GD1 Filter" <> '' THEN

     SETFILTER("Global Dimension 1 Filter",usersetup."GD1 Filter");

    thats all. Check the Field you defined in User Setup is having valid filter and the dimension sequence is correct like The Value you define is the valid value of Global Dimension 1 defined in your General Ledger Setup.

  • Verified answer
    Community Member Profile Picture
    on at

    Hi Saurav/Ashwini,

    It now works. This is the code I used.

    UserSetup.GET(USERID);

    IF Item."Global Dimension 1 Filter" = '' THEN

      SETFILTER("Global Dimension 1 Filter",UserSetup."Global Dimension 1 Code");

    Thank you so much guys...

    Best Regards,

    Earl

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 NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans