Calculated Columns - Can I Declare Variables in Expressions

Hi,

Is it possible to declare ans use a variable in the expression of a calculated column?

Idea was something like:
Dim StockPrev as Integer;
StockPrev:=[EXIST.STKREAL]+[EXIST.QTDENCFOR]-[EXIST.QTDENCCLI]
II(StockPrev<[EXIST.STKREAL] or StockPrev<0),[EXIST.STKMIN]-StockPrev,0)

What i want to return is the result of IIF; but I would like to use variables to make several calculations before.

Thanks

Comments

  • edited 7:02PM
    read FRNetUserManual-en.pdf, script section and example, is that what you wanted?
  • edited 7:02PM
    ipong wrote: »
    read FRNetUserManual-en.pdf, script section and example, is that what you wanted?

    Not exactly: in this case I was looking at the possibility to do this at the data source level, in the expression of a Calculated Column.

    I can create a calculated Column named StkPrev, and assign the expression as:
    [EXIST.STKREAL]+[EXIST.QTDENCFOR]-[EXIST.QTDENCCLI]

    What I would like to know if I can declare and use variables at this level, or if the use of variables is reserved to the script level.






  • edited October 2016
    There are two methods for calculated columns :

    1. in textobject, the formula is enclosed by square brackets, create expression like this :

    EXIST.STKREAL] + [EXIST.QTDENCFOR] - [EXIST.QTDENCCLI


    2. use script, more flexible, with c# you can code anything :
    namespace FastReport
    {
      public class ReportScript
      {
        private decimal StkPrev;
    
        private void Data1_BeforePrint(object sender, EventArgs e)
        {
          StkPrev = (Decimal)Report.GetColumnValue("EXIST.STKREAL") + (Decimal)Report.GetColumnValue("EXIST.QTDENCFOR") - (Decimal)Report.GetColumnValue("EXIST.QTDENCCLI");
        }
      }
    }
    </ScriptText>
    

    then create textobject with expression [StkPrev] , variable StkPrev in script can be used as an expression in textobject.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.