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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Business Central forum

Filter line records with filtered header records.

(0) ShareShare
ReportReport
Posted on by 358
So I am trying to sum the Base and Amount of VAT Entry Table.
But for only those records that have a particular Global Dimension.
So from the GL Entry Table I can get all the Document No. filtered on the Global Dimension 1 I want.
Then I want to filter the VAT Entry table with those Document No. found from GL Entry table and Sum their Base and Amount.
Here is what and not getting the expected result for the sake of this example we will call the Global Dimension 1 as 'AB'
On my report's (which has VAT Entry as its dataitem) onaftergetrecord()
GLEntry.SETFILTER("Global Dimension 1 Code", 'AB');
"VAT Entry".SETFILTER("Document No.", GLEntry."Document No.");
"VAT Entry".SETFILTER("Type", 'Sale');
"VAT Entry".SETFILTER("VAT Prod. Posting Group", '5% VAT');
IF "VAT Entry".FINDSET THEN BEGIN
   REPEAT
    TotalPS := TotalPS  + "VAT Entry".Base;
    TotalVATAmountPS := TotalVATAmountPS + "VAT Entry".Amount;
    UNTIL "VAT Entry".NEXT=0;
  END;
The result I get tells me GLEntry.SETFILTER("Global Dimension 1 Code", 'AB'); didn't work.
Any hint would be highly appreciated thanks in advance.
I have the same question (0)
  • Suggested answer
    Suresh Kulla Profile Picture
    50,269 Super User 2026 Season 1 on at

    You have applied the filter on the GLEntry but you never retrieved the record your code should look something like this

    GLEntry.SETFILTER("Global Dimension 1 Code", 'AB');

    IF GLEntry.FINDSET THEN

      REPEAT

    "VAT Entry".SETFILTER("Document No.", GLEntry."Document No.");

    "VAT Entry".SETFILTER("Type", 'Sale');

    "VAT Entry".SETFILTER("VAT Prod. Posting Group", '5% VAT');

    IF "VAT Entry".FINDSET THEN BEGIN

      REPEAT

       TotalPS := TotalPS  + "VAT Entry".Base;

       TotalVATAmountPS := TotalVATAmountPS + "VAT Entry".Amount;

       UNTIL "VAT Entry".NEXT=0;

     END;

    UNTIL GLEntry.NEXT = 0

  • Suggested answer
    Olister Rumao Profile Picture
    4,009 on at

    Hi Mysamza,

    You can do in this way. This way can also be used for all the dimension including ShortcutDimension 1&2

    There is a Table called Dimension Set Entry(480) which contains all the Dimensions Applied to G/L Entries.

    You can filter this Table with Dimension Code to get the Dimension Set ID.

    This Dimension Set ID is set on G/L Entry to indicate all the Dimensions applied to G/L Entries.

    Rec_DimensionSetEntry.SETFILTER("Dimension Value Code",'AB');

    IF Rec_DimensionSetEntry.FINDFIRST THEN

     REPEAT

        GLEntry.SETRANGE("Dimension Set ID",Rec_DimensionSetEntry."Dimension Set ID");

        IF GLEntry.FINDSET THEN

           REPEAT

             "VAT Entry".SETFILTER("Document No.", GLEntry."Document No.");

             "VAT Entry".SETFILTER("Type", 'Sale');

             "VAT Entry".SETFILTER("VAT Prod. Posting Group", '5% VAT');

              IF "VAT Entry".FINDSET THEN BEGIN

              REPEAT

                        TotalPS := TotalPS  + "VAT Entry".Base;

                        TotalVATAmountPS := TotalVATAmountPS + "VAT Entry".Amount;

               UNTIL "VAT Entry".NEXT=0;

              END;

           UNTIL Rec_GLEntry.NEXT=0;

     UNTIL Rec_DimensionSetEntry.NEXT=0;

    This code should resolve your query.

    Let me know if you need more help!.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans