Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Andrei_Faibich
Contributor III
Contributor III

Dimension selection depending on a Filter state

Hi,

I want to have  a dimension to be changed on my Line chart depending on a selection in a 'Period' field. For example if 'Today' is selected I want to have hour granularity, if 'This year' is selected I want to have month granularity. I have appropriate fields.

So I am trying to use this expression for my dimension field:

= if(Period = 'Today', Hour,
         (if(Period = 'Yesterday', Hour,
                (if(Period = 'This week', Weekday,
                        (if(Period = 'This month', Day,
                               (if(Period = 'This year', Month, Day)
                               )
                            )
                        )
                    )
                )
            )
        )
   )

But, it doesn't work.

What I am missing or doing wrong?

Thanks for any advises.

Labels (3)
1 Solution

Accepted Solutions
Andrei_Faibich
Contributor III
Contributor III
Author

I have got a solution to my problem.

We need to create a set of variables with field names assigned:

vHour = CanonicalHour

vDay = CanonicalDay

vMonth = CanonicalMonth

etc.

After we should create a variable with condutional selection:

vDimension = if(GetFieldSelections(Period) = 'This month', vDay,
                             if(GetFieldSelections(Period) = 'This year', vMonth, vHour   // and so on
                                )
                           )

And finally we write in our dimension expression:

$(=$(vDimension))

Voila, it works)

 

View solution in original post

3 Replies
sidhiq91
Specialist II
Specialist II

@Andrei_Faibich Did you try creating Drill down Dimension? 

First you need to create a Drill Down Master Item by Adding all the fields required.

Use the same Drill Down Dimension in the Dimension of line chart and Filter Pane

Please refer below link for additional Details.

https://help.qlik.com/en-US/sense/September2017/Subsystems/Hub/Content/Dimensions/create-drill-down-...

If this resolves your issue, please like and accept it as a solution.

Andrei_Faibich
Contributor III
Contributor III
Author

Thanks for the prompt reply, but

I need this logic to be hardcoded, user selects only values from the field 'Period'!

Andrei_Faibich
Contributor III
Contributor III
Author

I have got a solution to my problem.

We need to create a set of variables with field names assigned:

vHour = CanonicalHour

vDay = CanonicalDay

vMonth = CanonicalMonth

etc.

After we should create a variable with condutional selection:

vDimension = if(GetFieldSelections(Period) = 'This month', vDay,
                             if(GetFieldSelections(Period) = 'This year', vMonth, vHour   // and so on
                                )
                           )

And finally we write in our dimension expression:

$(=$(vDimension))

Voila, it works)