3 Replies Latest reply: Mar 23, 2013 1:43 AM by Sushil Kumar RSS

    Incorporating if statements within variable expressions

      Hello -


      My data source has three columns:  Year, Country, Sales $ (sales dollars by different countries from 2008-2012).  In QV I created two variables called "Start Year" and "End Year".  I then created an input box with with these two variables.  From an end-user perspective, the user enters a "start year" (2010 for example) and an "end year" (2012 for example).  The results are displayed in a straight table, where sales $ are shown by country in "start year" and "end year" columns.  The expressions used to display are below:


      Sum({$<Year ={$(vStartYear)}>}(Sales))

      Sum({$<Year ={$(vEndYear)}>}(Sales))


      I need to incorporate logic that says "if the year entered is less than 2012, divide sales by 1.3" (for either start or end year).  How do I do this?  I have other bar charts where I use the expression if (Year < 2012, (Sum (Sales)/1.3),(Sum (Sales)) successfully


      (before anyone suggest that I just divide the sales totals by 1.3 in the source data, I'm simply using 1.3 as a proxy for this example.  In my actual QV solution, the "1.3" is a variable that can be changed by the user)