Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
Jennell_McIntire
Employee
Employee

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.

Example of bar charts.png

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

9 Comments