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

Filter on a report for integers values using C/AL

(0) ShareShare
ReportReport
Posted on by

Hi All,

I am in a scenario where I need to filter data in a report for a specific integer values/Dateformula using C/AL code. The idea is that for a specific item classification and the value which are specified in the if statement should only the report display the result. Thanks in advance.

Here is a snippet of the code

On AfterGetRecord
DiffDate := FirstD - SecondD;
DivDate :=ROUND(DiffDate/30,1,'<');
StrCon :=FORMAT(DivDate)+Text006;
EVALUATE(SLOBWindowsPeriod,FORMAT(StrCon));

IF DivDate >=12 THEN
Item.SETFILTER(Item."Classification Code",'CON')
ELSE IF DivDate >=24 THEN
Item.SETFILTER(Item."Classification Code",'OPS')
ELSE IF DivDate >=48 THEN
Item.SETFILTER(Item."Classification Code",'INS')

// The above code is supposed to filter data for
//the specific Item classification based on the if statement
// but it didnit give the required results

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Mohana Yadav Profile Picture
    61,204 Super User 2026 Season 1 on at

    As per your code, if the DivDate is 50 then  also first condition is true (>12) and it will never come to ELSE Part.

    you have to also mention < value in conditions

    IF DivDate >=12 AND DivDate < 24 THEN

    Item.SETFILTER(Item."Classification Code",'CON')

    ELSE IF DivDate >=24 AND DivDate < 48 THEN

    Item.SETFILTER(Item."Classification Code",'OPS')

    ELSE IF DivDate >=48 THEN

    Item.SETFILTER(Item."Classification Code",'INS');

  • Community Member Profile Picture
    on at

    Hi Mohan,

    thanks for your reply

    I get an error that type conversion is not possible because 1 of the operators contains an invalid type:   Integer AND Integer.

  • Suggested answer
    Mohana Yadav Profile Picture
    61,204 Super User 2026 Season 1 on at

    That is just a code sample. you have fix it as per syntax.

    like

    IF (DivDate >=12) AND (DivDate < 24) THEN

  • Suggested answer
    Suresh Kulla Profile Picture
    50,269 Super User 2026 Season 1 on at

    Eri,

    As Mohana in your code use parenthesis for every condition for example for your above code

    IF (DivDate >=12) AND (DivDate < 24) THEN
    Item.SETFILTER(Item."Classification Code",'CON')
    ELSE IF (DivDate >=24) AND (DivDate < 48) THEN
    Item.SETFILTER(Item."Classification Code",'OPS')
    ELSE IF (DivDate >=48) THEN
    Item.SETFILTER(Item."Classification Code",'INS');


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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans