Rotation in a report of the last month

markyTmarkyT Member Posts: 120
Hi, I've a report on, in sections, calculate the "Invoiced Quantity" rotation. It do it on the last 6 months, 3 months and it runs well. But and now I want 1 month (the last month), but I can't. I've the following:

//6 Months
"Item Ledger Entry".SETRANGE("Posting Date",CALCDATE('<-6M>',WORKDATE),WORKDATE);

//3 Months
WITH "Item Ledger Entry" DO BEGIN;
IF ("Posting Date" >= CALCDATE('<-3M>',WORKDATE)) AND
("Posting Date" <= WORKDATE) THEN
3Month:="Invoiced Quantity";
END;

How can I do the last month, please?
Thanks in advance.

Comments

  • mohana_cse06mohana_cse06 Member Posts: 5,504
    markyT wrote:
    //6 Months
    "Item Ledger Entry".SETRANGE("Posting Date",CALCDATE('<-6M>',WORKDATE),WORKDATE);

    //3 Months
    IF ("Posting Date" >= CALCDATE('<-3M>',WORKDATE)) AND
    How can I do the last month, please?
    Cant you guess for 1 month? :-k
  • ufukufuk Member Posts: 514
    IF you want to calculate between the first and last date of the month then:
    SETRANGE("POSTİNG DATE",(calcdate('<CM-2M+1D>',WORKDATE)),(calcdate('<-CM-1D>',WORKDATE))
    

    If you want to calculate this based on a day then -1M & +1M
    Ufuk Asci
    Pargesoft
  • markyTmarkyT Member Posts: 120
    SETRANGE("POSTİNG DATE",(calcdate('<CM-2M+1D>',WORKDATE)),(calcdate('<-CM-1D>',WORKDATE)))

    Thanks you very much, it works!!, but only a thing. I put it in a body section and in footers shows the variables of each rotation. If I put the code like this, all show the same rotation. I need dump the result to a variable as I did on 3 months for example. How can I do it please?.
    Thanks for your help.
  • vijay_gvijay_g Member Posts: 884
    Your question is not so much clear whatever you want can you show the screen shot of your report preview?

    Your value is repeating, It seems that you have not initialized the variable.
  • ufukufuk Member Posts: 514
    markyT wrote:

    Thanks you very much, it works!!, but only a thing. I put it in a body section and in footers shows the variables of each rotation. If I put the code like this, all show the same rotation. I need dump the result to a variable as I did on 3 months for example. How can I do it please?.
    Thanks for your help.

    I didn't understand exactly. What's the difference between 3 months and 1 month? If 3 months works as you want then 1 month range should do too.

    I suggest debugging. This way you can see what happens in your report step by step.
    Ufuk Asci
    Pargesoft
  • ufukufuk Member Posts: 514
    markyT wrote:

    Thanks you very much, it works!!, but only a thing. I put it in a body section and in footers shows the variables of each rotation. If I put the code like this, all show the same rotation. I need dump the result to a variable as I did on 3 months for example. How can I do it please?.
    Thanks for your help.

    I didn't understand exactly. What's the difference between 3 months and 1 month? If 3 months works as you want then 1 month should do too.

    I suggest debugging. This way you can see what happens in your report step by step.
    Ufuk Asci
    Pargesoft
  • markyTmarkyT Member Posts: 120
    Thanks for reply, I'll try to explain:

    //First I calculate 6M:
    "Item Ledger Entry".SETRANGE("Posting Date",CALCDATE('<-6M>',WORKDATE),WORKDATE);

    //After 3M:
    WITH "Item Ledger Entry" DO BEGIN;
    IF ("Posting Date" >= CALCDATE('<-3M>',WORKDATE)) AND
    ("Posting Date" <= WORKDATE) THEN
    Sum3M:="Invoiced Quantity";
    END;

    And now i want to calculate the last month. The I create Sum1M variable and try to do the code. I suppose that it should be as easy as do the same that with 3M did, but doesn't works. I've try that you answered:
    SETRANGE("POSTİNG DATE",(calcdate('<CM-2M+1D>',WORKDATE)),(calcdate('<-CM-1D>',WORKDATE)))

    but i can't asign it the result to my Sum1M variable. How can I do it please?.
    Thanks in adavance.
  • markyTmarkyT Member Posts: 120
    Thanks, sorry but I try put the entire code but it says that there is too many characters. Also I try to attach the txt but says the same: "the txt contains too few characters".
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    The code which you have written along with above code only..not all code in object..
    and also where did you write?
  • markyTmarkyT Member Posts: 120
    Thanks. Well, the code is almost what I had already written. I've have change some words and variables into English. Here it is:
    { PROPERTIES
          {
            DataItemIndent=1;
            DataItemTable=Table32;
            DataItemTableView=SORTING(Entry Type,Item No.,Variant Code,Drop Shipment,Location Code,Posting Date)
                              WHERE(Entry Type=FILTER(Sale));
            OnPreDataItem=BEGIN
                             CurrReport.CREATETOTALS("Invoiced Quantity");
                               CurrReport.CREATETOTALS(Sum3M);
                               CurrReport.CREATETOTALS(Sum1M);
    
    
                            /////Last 6 months
                            "Item Ledger Entry".SETRANGE("Posting Date",CALCDATE('<-6M>',WORKDATE),WORKDATE);
                          END;
    
            DataItemLink=Item No.=FIELD(No.);
          }
          SECTIONS
          {
            { PROPERTIES
              {
                SectionType=Body;
                SectionWidth=18900;
                SectionHeight=0;
                OnPreSection=BEGIN
                               
                               month:= FORMAT(CALCDATE('<-1M>',TODAY),0,'<Month Text>');
    
                              
                               WITH "Item Ledger Entry" DO BEGIN;
                               IF ("Posting Date" >= CALCDATE('<-3M>',WORKDATE)) AND
                               ("Posting Date" <= WORKDATE) THEN
                               Sum3M:="Invoiced Quantity";
                               END;
    
                             
                               WITH "Item Ledger Entry" DO BEGIN;
                               "Item Ledger Entry".SETRANGE("Posting Date",(CALCDATE('<-1M>',WORKDATE)),WORKDATE);
                               Sum1M:="Invoiced Quantity";
                               END;
    
                             END;
    
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Cant we do it similar to 3M?
    WITH "Item Ledger Entry" DO BEGIN;
      IF ("Posting Date" >= CALCDATE('<-1M>',WORKDATE)) AND
        ("Posting Date" <= WORKDATE) 
      THEN
        Sum1M:="Invoiced Quantity";
    END;
    
  • markyTmarkyT Member Posts: 120
    I can't believe it..... Indeed was it, already works =D> , but I had proved it, was the first thing I did but the result was not correct, maybe had some filter or something that was making the result was not correct, I don't know what happend.. :oops: .
    Well, thank you very much for your help and time. Sorry for the dismissal.
    Thanks again.
Sign In or Register to comment.