Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calculated Dimension

Hi There

I have a basic graph with sales for example.

I want the dimension for the graph to be Year when no year is selected or Month when there is a year selected.

To test this is possible i enter the following in the calculated dimension expression:

=if(1=1,Year,Month)

This work when i change the 1=1 to 1<>1, the dimension changes to Month or Year accordingly.

BUT ic annot get this to work:

=if(count(distinct(Year))=1,Month,Year)

It just says error in calculated dimension, obviously I am just checking to see if a year is selected and then change the dimension.

What am I doing wrong ?

Thanx

1 Solution

Accepted Solutions
Not applicable
Author

Try:

=if(GetSelectedCount(Year)>0, Month, Year)


There are probably quite a few different methods to accomplish this, but I like the built-in QlikView selection functions. Also, see GetFieldSelections(), which will give you a list of the actual selections in a field.

EDIT: I think the problem with your functions is it should be:

=if(count(distinct Year)=1,Month,Year)


View solution in original post

1 Reply
Not applicable
Author

Try:

=if(GetSelectedCount(Year)>0, Month, Year)


There are probably quite a few different methods to accomplish this, but I like the built-in QlikView selection functions. Also, see GetFieldSelections(), which will give you a list of the actual selections in a field.

EDIT: I think the problem with your functions is it should be:

=if(count(distinct Year)=1,Month,Year)