Qlik Community

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
IMPORTANT security patches for GeoAnalytics Server available to download: READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
juriengroot
Contributor III
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])

1 Solution

Accepted Solutions
OmarBenSalem
Partner
Partner

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...

View solution in original post

6 Replies
OmarBenSalem
Partner
Partner

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
Contributor III
Contributor III
Author

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
Partner
Partner

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
Contributor III
Contributor III
Author

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

OmarBenSalem
Partner
Partner

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
Contributor III
Contributor III
Author

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