12 Replies Latest reply: Oct 25, 2017 6:14 PM by Fabrizio Giorgio RSS

    Variable in Script - Assign Value based on If Statement

    Fabrizio Giorgio

      Hi there,


      I'm hoping this is an easy question, but i've never created variables in my script before so just after some help.


      I have an average sales calculation in one of my reports that requires a dynamic value as part of the formula.


      This value needs to change depending on the current Financial Period (Period 1-12 which represent Months)


      Let's name this changing value "vSalesAverageCalc"


      I have a variable that has been created in the past, which picks up the current Financial Period (vReportCurrent_Period)


      What I need in my script is the following logical statement: (rough idea - I know this incorrect syntax)


      If vReportCurrent_Period is 1,2 or 3, Let vSalesAverageCalc = 24

      If vReportCurrent_Period is 4,5 or 6 Let vSalesAverageCalc = 15

      If vReportCurrent_Period is 7,8 or 9 Let vSalesAverageCalc = 18

      If vReportCurrent_Period is 10,11 or 12 Let vSalesAverageCalc = 21

      is someone able to help me with this syntax for this variable?

      and should the variable already exist in the .qvw or is it created dynamically when the script runs?

      Thanks in advance everybody!!

      Cheers - Fab