7 Replies Latest reply: Jun 7, 2017 7:56 AM by Sunny Talwar RSS

    How to write an expression that dynamicly identifies a year?

    Maria Poulsen

      I have a dataset that shows the nationality among foreign students.
      I have data for the years 2013-2016.

      I want to make a straight table with nationality as a dimension and show the number of students in each category of nationality for every year, so that I end up with 4 columns with numbers.



      I have defined a vMaxAargang variable (max year=2016) and a vMinAargang (min year=2013).

      In the expressions tab I write this for the year 2016:

      =count({<[Hjemland2]={'Udenlandsk'}, [Type_stat]={'Heltid'}, [type_stat2]={'Udl Heltid'}, [over_udd]={'Bachelor', 'Kandidat'}, [aargang]={$(vMaxAargang)} >}PERSON_ID


      This gives me the data that I want for 2016.


      My problem is to get the data for 2015, 2014 and 2013.

      I have tried to modify the above code to go 1(,2,3) years back – without luck:

      =count({<[Hjemland2]={'Udenlandsk'}, [Type_stat]={'Heltid'}, [type_stat2]={'Udl Heltid'}, [over_udd]={'Bachelor', 'Kandidat'}, [aargang]={$(vMaxAargang-1)} >}PERSON_ID


      =count({<[Hjemland2]={'Udenlandsk'}, [Type_stat]={'Heltid'}, [type_stat2]={'Udl Heltid'}, [over_udd]={'Bachelor', 'Kandidat'}, [aargang]={$(vMaxAargang)-1} >}PERSON_ID


      How do I tell QV to go X years back in the script without hardcoding?