Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
mikegrattan
Creator III
Creator III

Change to alternative dimension when Time dimension changes

In my application I have some line charts with the primary dimension as Week and the alternative dimension as Date. When a user filters their view by Period or Year, (but not Week or Date), I'd like the chart's primary dimension to be Week. When the user filters down to the Week level, I'd like to change the chart's primary dimension to Date.

Is there a way to do this automatically?

1 Solution

Accepted Solutions
hector_munoz
Specialist
Specialist

Hi Mike,

Try to create a variable vdWeeksAvailable = Count(DISTINCT PoolWeek) and replace the above calculated dimension by If(vdWeeksAvailable >1, PoolWeek,Date).

Regards,

H

View solution in original post

6 Replies
hector_munoz
Specialist
Specialist

Hi Mike,

I donot know if understand well what you say so... If you need your line charts have Week dimension when there are many weeks available in resulting selections and Date when is only a week available you could try the following calculated dimension: If(Count(DISTINCT Week) = 1, Date, Week)

Regards,

H

mikegrattan
Creator III
Creator III
Author

Thank you for your response Hector. I tried the following formula based on your suggestion:

If(COUNT(DISTINCT PoolWeek) >1, PoolWeek,Date)

Unfortunately, Qlik Sense tells me this is an "invalid dimension", even though the formula has no syntax issues.

Thanks,

Mike

hector_munoz
Specialist
Specialist

Hi Mike,

Try to create a variable vdWeeksAvailable = Count(DISTINCT PoolWeek) and replace the above calculated dimension by If(vdWeeksAvailable >1, PoolWeek,Date).

Regards,

H

mikegrattan
Creator III
Creator III
Author

The suggested use of a variable seems to be on the right track. The expression no longer gives an "invalid dimension" message.  However, it doesn't work as expected; if I filter on one week it should show me Dates, but it still only shows the week.

Calculated Week_Date dimension.jpg

mikegrattan
Creator III
Creator III
Author

Figured it out.  The variable needs to be defined with an '=' sign and the formula for the chart needs $ expansion:

vdWeeksAvailable:  =Count(DISTINCT) PoolWeek)

Now the following formula works as expected:

If($(=vdWeeksAvailable) >1,PoolWeek,Date(Date))

hector_munoz
Specialist
Specialist

Congrats, Mike! Glad it is solved!