Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

mikegrattan
Contributor II

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
Valued Contributor

Re: Change to alternative dimension when Time dimension changes

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

6 Replies
hector_munoz
Valued Contributor

Re: Change to alternative dimension when Time dimension changes

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
Contributor II

Re: Change to alternative dimension when Time dimension changes

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
Valued Contributor

Re: Change to alternative dimension when Time dimension changes

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
Contributor II

Re: Change to alternative dimension when Time dimension changes

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
Contributor II

Re: Change to alternative dimension when Time dimension changes

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
Valued Contributor

Re: Change to alternative dimension when Time dimension changes

Congrats, Mike! Glad it is solved!