Search code examples
dynamicchartsqliksensedynamic-tables

How to dynamically Change Column name(column header) with filter in Qlik Sense


I have a Filter in my dashboard as Financial Year. In that filter there are currently two years. 2021 and 2022 however as data is loaded there will be 2023 also so I want column name RANK to change dynamically to the year I select from filter pane. For eg. If year 2022 is selected from filter pane it should show RANK 2022. Please anyone help me with this

COMPANY NAME RANK 2022
A 21 B 4 C 7

Title should change dynamically

If year 2022 is selected

COMPANY NAME RANK 2022
A 21 B 4 C 7

if year 2023 is selected COMPANY NAME RANK 2022
A 21 B 4 C 7


Solution

  • If I'm understanding correctly, you could try one of these options by updating the Label property for your [Rank] field:

    Only() function

    ='Rank ' & Only([Financial Year])

    This uses the Only() function to display the currently possible [Financial Year] only if one year is possible. That means that if you select multiple years, the [Rank] values will still filter correctly to those selected years but the column name will not display the years since it will return a value if there is only one unique value to return. Note that this is an aggregation function so it's not strictly based on what's selected. If your data model changed such that there was only one [Financial Year] value loaded, the header would display that year even if you weren't actually selecting it. That's why I use the term "possible" instead of "selected."

    Screen recording GIF of a Qlik Sense header being updated using the Only function

    Concat() function

    ='Rank ' & Concat(distinct [Financial Year], ', ')

    This will make the header display all distinct, possible years as a comma-separated list. This means if you have multiple possible or selected years, they'll all be shown in the header. Just like the Only() function, this is an aggregation, so it's not strictly based on selections.

    Screen recording GIF of a Qlik Sense header being updated using the Concat function

    GetFieldSelections() function

    ='Rank ' & GetFieldSelections([Financial Year], ', ')

    This function works similarly to the Concat() function, except that it is not based on possible values but instead based strictly on selected values.

    Screen recording GIF of a Qlik Sense header being updated using the GetFieldSelections function

    if(), GetFieldSelections(), and GetSelectedCount() functions

    ='Rank ' &
    if( GetSelectedCount([Financial Year]) > 1, 'Multiple Years',
    if( GetSelectedCount([Financial Year]) = 1, GetFieldSelections([Financial Year])))
    

    This uses an if() statement to see how many years are selected. If more than one year is selected, it will display the text "Multiple Years." If only one year is selected, it will display that year. If no years are selected, it will not display anything.

    Screen recording GIF of a Qlik Sense header being updated using the If, GetFieldSelections, and GetSelectedCount functions