7 Replies Latest reply: Nov 12, 2014 7:06 AM by jagan mohan rao appala RSS

    Using a variable in a graph title


      I am getting up and running on Qlik Sense. So far I'm really impressed.


      I'm seeing an issue with being able to use functions/variables in a graph title. In QlikView, I was able to set a graph title to:


      ='Week of ' & makeweekdate(GetFieldSelections(Year),GetFieldSelections(Week)) & 'Hours By Employee'





      In Qlik Sense, not only can I not use this expression, but I can't even seem to use my "Week" variable in something simple like:

      'Week: ' & Week


      I can only display the week number if the only thing I have in my title is:



      At that point it will successfully show the week number that is selected in the "Week" filter object.






        • Re: Using a variable in a graph title
          Gysbert Wassenaar

          Are you sure the exact same expression does really work in the Qlikview document without first selecting a week?

          It shouldn't.

          'Week: ' & Week is really 'Week: ' & only(Week). And only(Week) can only return a value if only one value of Week is possible. That's why you first need to select a value. You could try 'Week: ' & max(Week) if you want the latest possible week regardless of if you first selected a week or not.


          GetFieldSelections(Week) likewise needs selections in the Week field to return a value. But if you select more than one value then it will return the selected values as a comma separated list. But then the makeweekdate function won't return a value anymore, since it needs an integer for the week parameter, not a list of values.

          • Re: Using a variable in a graph title
            jagan mohan rao appala


            There is no variables in frontend, but Instead of using a variable you can directly use expression like below


            Qliksense Title.png



            • Re: Using a variable in a graph title

              Hi Gysbert, Jagan,

              Thanks for your responses. I'm getting slightly different behavior now, but I'm still unable to get it to work the way it did in QlikView. In particular, the expression "makeweekdate(GetFieldSelections(Year),GetFieldSelections(Week))" does not seem to work. Here is a sequence of screenshots to show you that "Week" and "Year" have been selected appropriately, but that makeweekdate() does not work. Have either of you seen makeweekdate() work in Qlik Sense?










              • Re: Using a variable in a graph title

                Hi all,

                Thanks for the responses.


                I suspected that Qlik Sense wasn't liking my use of "Week" and "Year", since those seem to be keywords.


                I changed those variables to "EntryWeek" and "EntryYear", reloaded the data, and rebuilt the filters and the modified the expression appropriately. No luck.


                I took a look at Josh's "Test App", which indeed worked appropriately. Thanks for that example, Josh.


                For kicks, I changed my variable names to "OrderWeek" and "OrderYear", like in Josh's example. I went through the same cleanup sequence as before, and this time it worked. Strange.


                I went back to "EntryWeek" and "EntryYear"- again, no luck.

                I went back to "OrderWeek" and "OrderYear"- again, it worked.


                I went back to "EntryWeek" and "EntryYear"- this time, it worked.


                I suspect there is something flaky going on with the "Title" box. I have noticed a few weird things where changes sometimes don't seem to take effect. When it gets in that state, I clear the field entirely, start from scratch, and then get what I'm looking for.


                Anyway, I'm still a bit confused, but at least things are working. I'll spend a bit more time on it to see if I can figure out where things went wrong. If I find anything interesting, I'll follow up with a post.


                Thanks again for the responses.