Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

juriengroot
New Contributor III

Week / Month select with variable

I have a variable and like to be able to switch between Weeks and Months. For some reason it is not working. Is this a bug or some other reason?

For example:

if(vTimePeriod='MonthSelected',[Ship Month],[Order Month])

But this one isn't working

if(vTimePeriod='MonthSelected',[Order Month],[Order Week])

Tags (3)
1 Solution

Accepted Solutions
omarbensalem
Esteemed Contributor

Re: Week / Month select with variable

What I would is as follow:

Create an inline table :

load * inline [

Dim, DimID

Month, 1

Week, 2

];

The create a variable :

vDim = if(DimID=1,YourMonthField,YourWeekField) :

And in your chart, as dimension, choose : $(vDim)

And add you Dim field as a filter

Hope you're satisfied...

6 Replies
omarbensalem
Esteemed Contributor

Re: Week / Month select with variable

What do you mean by switching between Weeks and months?
You want to have 2 dimensions per graph? and be able to alter btwn them on selection?

juriengroot
New Contributor III

Re: Week / Month select with variable

I have a variable with two options, Weeks and Months.

I want a chart or table with a dimension and depending on the choice of variable it needs to show weeks or months.

omarbensalem
Esteemed Contributor

Re: Week / Month select with variable

For a chart, you won't need to create variables for that, you only have to add an alternative dimension:

For example :

Dimension: Year

Alternative Dimension: Region

Measure: ...

In your case: dimension: Month, alternative : week

:

Capture.PNG

And then you simply  click to choose what dimension you wanna work with :

Capture.PNG

Capture.PNG

juriengroot
New Contributor III

Re: Week / Month select with variable

I know alternative dimensions , but for my case I need it as a variable. So any help with a variable would be great!

omarbensalem
Esteemed Contributor

Re: Week / Month select with variable

What I would is as follow:

Create an inline table :

load * inline [

Dim, DimID

Month, 1

Week, 2

];

The create a variable :

vDim = if(DimID=1,YourMonthField,YourWeekField) :

And in your chart, as dimension, choose : $(vDim)

And add you Dim field as a filter

Hope you're satisfied...

juriengroot
New Contributor III

Re: Week / Month select with variable

That works indeed. While a variable switch didn't work, the inline dimension made the difference. Strange, but thanks!