Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

m_schlag
New Contributor

Dynamic reference line based on filter

Is it possible to create a dynamic reference line based on what filter is selected?  I am displaying work hours by employee and there are options for calendar year, calendar month year (Jan-2018) and then calendar week.  If they select a year, I want the reference line to be 2080 hours for the calendar year, 160 for the calendar month year, and 40 for the calendar week.  Thanks.

1 Solution

Accepted Solutions
rittermd
Honored Contributor

Re: Dynamic reference line based on filter

You might need to reverse the order of your if statements so that you are checking for Week first and Year last.  That might work.

5 Replies
rittermd
Honored Contributor

Re: Dynamic reference line based on filter

I am not sure that this would work.  But you could try using GetFieldSelections(filter) and depending on what value is returned set the value to the appropriate number value in your setup for the reference line. 

Hopefully that made sense.

rittermd
Honored Contributor

Re: Dynamic reference line based on filter

I just tested this in one of my apps and it works.

=If (GetFieldSelections(ownerid_Name) like 'Argolo*',1,.5)

You just need to modify this to check your filter field and the values (Year, Month, etc.) and the numeric value that you want the line to show and that should work.

m_schlag
New Contributor

Re: Dynamic reference line based on filter

That worked thank you very much, but not totally the way I wanted, so I probably didn't explain myself fully.  If I select one of the three filters (Year, Month Year, or Week) the reference line shows up.  But if I first select the year, then a month and finally a week, the reference line stays at the year level.  I would want the line to change based on the last filter used.

Here is the expression that I used.

=If(GetFieldSelections([Labor Cal Year]) like '201*',2080,

     if(GetFieldSelections([Labor Month Year]) like '2017-*' or '2018-*',160,

         if(GetFieldSelections([Labor Cal Week]) like 'W*',40)))

rittermd
Honored Contributor

Re: Dynamic reference line based on filter

You might need to reverse the order of your if statements so that you are checking for Week first and Year last.  That might work.

m_schlag
New Contributor

Re: Dynamic reference line based on filter

That did the trick.  Thank you very much.