4 Replies Latest reply: Jun 6, 2017 4:52 AM by Maria Poulsen RSS

    How to make a chart showing the calculated percentage point difference between two periods?

    Maria Poulsen



      I have made a bar chart showing the percentage of the student mass, who are foreign students.

      I have data from 2013-2016 so far. Every year new data is added.

      The chart looks like this, with percentage on the y-axis:



      the code I used looks like this:


      =num(count({<over_udd={'Bachelor', 'Kandidat'},[Hjemland2]={'Udenlandsk'}>}PERSON_ID)/(sum({<over_udd={'Bachelor', 'Kandidat'}>}bestand_antal)))



      Now I would like to make a bar chart showing the percentage point difference from one year to the next.

      I thought it would be smart to make the code dynamic, so I don't have to maintain it, every time a new year is added.


      I have tried the folowwing code, but it does not work:

      =num(count({<over_udd={'Bachelor', 'Kandidat'},[Hjemland2]={'Udenlandsk'}>}PERSON_ID)/(sum({<over_udd={'Bachelor', 'Kandidat'}>}bestand_antal)))

      num(count({<over_udd={'Bachelor', 'Kandidat'},[Hjemland2]={'Udenlandsk'}, [Aargang]={Aargang}-1>}PERSON_ID) /(sum({<over_udd={'Bachelor', 'Kandidat'},[Aargang]={(Aargang}-1>}bestand_antal)))

      The first part is just a copy of the old code, whick shows the percentage number every year. So I thought that I could just copy it, and add a "go one year back and compare" statement (year=Aargang). But it says error in expression.


      How do I tell QV to compare the percentage from one year with the year before?

      I know that there will be no data in 2013, because it is the first year.

      I have made a vMinAargang and a vMaxAargang variable, but I haven't used them (yet).


      Kind regards