# Qlik Design Blog

All about product and Qlik solutions: scripting, data modeling, visual design, extensions, best practices, etc.

Announcements
QlikWorld Online 2021, May 10-12: Our Free, Virtual, Global Event REGISTER TODAY
Employee

## Use Case for ValueList Chart Function

The Demo Team recently built a mashup for the 2016 Oscars where we analyzed the nominees and award winners over the past 88 years.  The design for the mashup often showed nominees and winners in the same chart as seen below where the silver bar indicated nominations and the gold bar represented wins.

One requirement for the app was to color the number of nominations bar silver and the number of wins bar gold.  In the data model, we did not have a field that we could use as the dimension to show the coloring for nominations and winner so at the suggestion of Alexander Karlsson we used the ValueList chart function.  As noted in Qlik Sense Help, “ValueList() returns a set of listed values, which, when used in a calculated dimension, will form a synthetic dimension.”  In the Actresses bar chart above, we created the dimension using this syntax:

ValueList('Oscars', 'Nominations')

Thus creating a synthetic dimension with two possible values: Oscars and Nominations.  Then in the measure, we used an If statement to assign a measure to each list item in our ValueList dimension.

If(ValueList('Oscars', 'Nominations')='Oscars',

Count({<Actress_Win_flg={'1'} >} Distinct Film),

(Count(Distinct Film)-Count({<Actress_Win_flg={'1'} >} Distinct Film)))

If the dimension is ‘Oscars’ then we count the films where the actress won.  Otherwise, we count the nominations where the actress did not win.  This same logic was used to handle the coloring of the bars.  We colored the bars by using this expression:

If(ValueList('Oscars', 'Nominations')='Oscars', '#e1aa3d', '#ccc')

If the dimension is Oscars showing the wins, then color the bar gold otherwise color the bar silver.

The ValueList chart function provided what we needed to treat nominations and winners as if they were a dimension providing us the flexibility to vary the measures and coloring we wanted to use on the bars in the bar chart.  This solution saved us time from having to modify our data model to accommodate our design requirements.  The only difference between the ValueList synthetic dimension and a normal dimension is synthetic dimensions are not affected by selections.  Alexander Karlsson wrote a blog about ValueList as well as ValueLoop – check it out.

Thanks,

Jennell

Employee

Naresh,

Yes, a variable can replace the measure.  In place of the measure, simply enter \$(variablename).

Jennell

1,004 Views
Contributor

Hey jmc ,

How can i restrict my dimension to show only top 10 values in this case ? I tried all possible ways but nothing is working.

Prasoon

1,004 Views
Employee

Hi Prasoon,

You can set a limit on the dimension (like the Actor or Actress in my example).  In the properties for the dimension, under Limitation, you can select Fixed number and set it to Top 10.

Hope this helps.

Jennell

1,004 Views