Options

Totalscaused by (code variable)

JamieBrownJamieBrown Member Posts: 107
Hi,

This is another newb question so I'm guessing you guys will easily know a way round this...

I'm using the following to create a code variable from the "Post Code" field.
postcoderev := FORMAT(customer."post code",4);

This is fine, but I need to create group totals by this variable. I've tried using:
CurrReport.TOTALSCAUSEDBY = postcoderev;

But this doesn't work due to postcoderev not being an integer.

Is there another way around this?

thanks in advance.

Comments

  • PhennoPhenno Member Posts: 630
    You can't use this function in such way.
    TOTALSCAUSEDBY (Report)
    Use this function to determine which field caused a group total to be calculated - meaning determining which field changed contents and thereby concluded a group.

    IF CurrReport.TOTALSCAUSEDBY = FIELDNO(Item) THEN
    CurrReport.SHOWOUTPUT(FALSE); 
    


    Actually, you cannot make group totals for a variable by code.
  • David_CoxDavid_Cox Member Posts: 509
    You can only use the totalscausedby for phsical fields that are part of a key:

    You could try to use a buffer table, loop through and update the buffer, then report on the buffer table.
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • gulamdastagirgulamdastagir Member Posts: 411
    instead of using this



    Code:
    postcoderev := FORMAT(customer."post code",4);

    use this:
    Number :Integer

    Number := Customer.FIELDNO(customer."post code");

    IF CurrReport.TOTALSCAUSEDBY = Number THEN
    CurrReport.SHOWOUTPUT(FALSE);
    Regards,

    GD
  • JamieBrownJamieBrown Member Posts: 107
    Thanks guys, I think I'm going to cheat and add a new field & Key to the customer table.

    Gulamdastagir, sorry I should have mentioned that the "Post Code" field is alpha numeric.

    thanks
  • gulamdastagirgulamdastagir Member Posts: 411
    FIELDNO (Record)
    Use this function to return the number assigned to a field in the table description.

    Number := Record.FIELDNO(Field)
    Number
    Data type: integer
    The number of the field you selected.

    Record
    Data type: record
    The name of the record that contains the field.

    Field

    Data type: field
    The name of the field in the record


    It really doesnt matter what the datatype of the field isall u need is the name
    Regards,

    GD
  • mukesvemukesve Member Posts: 28
    Hi Jamie

    Try the following -

    Change in Table -
    Add a Key to the Customer Table for the Post Code

    Change in Report -
    Select Customer DataItem
    Open Properties
    Go to DatItemTableView and specify SORTING(Post Code)
    Go to GroupTotalFields and Specify PostCode

    Go to Sections and Add Group Header and Group Footer Section
    Write the following code in OnPreSection trigger of both the Section

    CurrReport.Showoutput(CurrReport.TotalsCausedBy=FieldNo("Post code"))

    Save the report and Test it.

    All the Best

    Mukesh :D
  • David_CoxDavid_Cox Member Posts: 509
    Hey Guys

    Read the original post, Jamie wants to group on part of a field value, from position 4 for some reason??

    Not sure why when we have Post Codes like these, and the first set of values are the County then District:
    SE17 3SN, BR8 7TW, W1 1WD Hmmmm :-k
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • mukesvemukesve Member Posts: 28
    Thanks David

    Now this should work

    Add one more field Post Code Group to Customer table and write the code in OnValidate trigger of PostCode so that whenever the postcode is changed, The Post Code Group should be populated with the formula -

    "Post Code Group" := FORMAT("post code",4);

    Add a key to Customer table for Post Code Group and use the Post Group Code instead of Post Code as mention in my previous solution.

    Mukesh Verma :D
Sign In or Register to comment.