Dynamic charts

    Dynamic charts

     

    There are 2 ways you can create dynamic charts in QlikView.  One way is to use 'Fast Change Type' in the General tab of the chart properties.

     

    The other way that we will cover next is to setup dynamic dimensions and expressions in the loadscript. This can be a very useful technique to implement to save on space on your sheet and allow users to select which type of chart they wish to view especially when there are many potential charts different users require.

     

    1. Using the same loadscript for the data as in the line chart example which is:

    CrossTable(Quarter, Amount, 2)
    LOAD Product,
    Customer,
    [Qtr 1],
    [Qtr 2],
    [Qtr 3],
    [Qtr 4]
    FROM
    SampleCustomerReports.xls
    (biff, embedded labels, table is [Source Data$]);

     

     

         2. Add the following inline table.

    dynamic_charts:
    LOAD * INLINE [
    "Graph Name", Dimension1, Dimension2, Expression
    "Sales Amount by Quarter", Quarter, Customer, "=sum(Amount)"
    "B Customers - Sales Amount by Quarter", Quarter, Customer, "=sum({<Customer={'B*'}>}Amount)"
    ]
    ;

     

    This table will be used to change the dimensions, expression of the chart.

     

    3. Create a new bar chart and make the following changes:

    • General tab:

                    Check the 'Show title in Char' option and set the text to:

                                    =[Graph Name]

                                    Select the Chart Type of Bar chart.

    • Dimensions
    • Add the 2 calculated dimensions to use the dimension1 and dimension2 fields in the inline table setup in the loadscript:

    =$(=Dimension1)
    =$(=Dimension2)

    • Expressions -Add the following expression:

                    $(=Expression)

    • Caption - Uncheck the option 'Show Caption'.
    • Click OK to display the chart.
    • Right click on the sheet and in the Fields tab add the field 'Graph Name' to the fields to be displayed in listboxes. Select an option in the Graph Name listbox, it will change the dimensions and expressions in the chart as you can see from the following 2 screenshots:

     

     

     

    Thanks

     

    Mark