Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
IMPORTANT security patches for GeoAnalytics Server available to download: READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
quantran
Creator
Creator

Using If and getselectedcount

I have a text object that I would like to display "Test" if there are selections made for the CostCenterCode with

getselectedcount(CostCenterCode).  Otherwise, display "Space."  I created the expression below and put it into the Text area of the Text Object.  I am not getting just the Test or Display.  I get a text with the code that I wrote.  I have researched but have not found anything to resolve this issue.  I hope you can help.

if(getselectedcount(CostCenterCode)<1, 'Test', 'Space');

1 Solution

Accepted Solutions
trdandamudi
Master II
Master II

You need to remove the semi colon at the end:

=if(getselectedcount(CostCenterCode)<1, 'Test', 'Space')

View solution in original post

8 Replies
trdandamudi
Master II
Master II

Try putting a equal (=) in the front:

=if(getselectedcount(CostCenterCode)<1, 'Test', 'Space')

Note: Also remove the colon at the end.

quantran
Creator
Creator
Author

I got an error message if I do that,

trdandamudi
Master II
Master II

You need to remove the semi colon at the end:

=if(getselectedcount(CostCenterCode)<1, 'Test', 'Space')

quantran
Creator
Creator
Author

atkinsow
Specialist II
Specialist II

Then you want

=if(getselectedcount(CostCenterCode)>0,'Test','Space')

The way you have it written now is less than 1.

quantran
Creator
Creator
Author

trdandamudi
Master II
Master II

Then you need to re-write the code as below:

=if(getselectedcount(CostCenterCode) > 0, 'Test', 'Space')

atkinsow
Specialist II
Specialist II

It's because CostCenterCode and CostCenterName are 2 difference fields.  If you want to check both you could do something like

=if(getselectedcount(CostCenterName)+getselectedcount(CostCenterCode)>0,'Test','Space')