Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Coming your way, the Qlik Data Revolution Virtual Summit. October 27-29. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Not applicable

Nested If...ElseIf statement in a textbox -- possible?

It's me again

I'm so appreciative of the help that this community has provided me thus far on my initial jouney into QlikView.  I currently have a tab that when activated, automatically selects two values for my 'Question' field ('Group' and 'Self').  I have a text box that I want to display text in, but I want it to change depending on what the selection is.  I'm going to try to explain as best as I can.

If both 'Group' and 'Self' are selected (which is the default for the tab), I want to display "Total Productivity".  If only 'Group' is selected, I want to display "Group Productivity", and if only 'Self' is selected, display "Self Productivity".  If neither is selected, display nothing.

I wrote it out as this:

IF Question = 'Group' THEN

    IF Question = 'Self' THEN

          Text = "Total Productivity"

    ELSE

          Text = "Group Productivity"

ELSEIF Question = 'Self' THEN

    Text = "Self Productivity"

ELSE

    Text = blank

But I don't know how to format it for Qlik.  I tried this:

=If(Question='Group',If(Question='Self',"Total Productivity","Group Productivity"),If (Question='Self',"Self Productivity","")

But that doesn't seem to work.  Any help would be greatly appreciated.

Thanks,

Tim

1 Solution

Accepted Solutions
Highlighted

I have seen that things selected with triggers sometime comes with ("Text1"|"Text2") in the current selection box. I would suggest creating a text box with GetFieldSelections(Question) and open the app (let the trigger go off) and then sending the text box object to excel. Copy and paste its content from Excel and paste it as an or statement:

=If(GetFieldSelections(Question)='Group, Self' or

     GetFieldSelections(Question) = 'NewText', 'Total Productivity',

If(GetFieldSelections(Question)='Group','Group Productivity',

If (GetFieldSelections(Question)='Self','Self Productivity',' ')))

View solution in original post

16 Replies
Highlighted

Not sure I understand, how can Question = 'Group' and 'Self' at the same time?

Highlighted
MVP
MVP

If(Question='Group' and Question='Self','Total Productivity',

If(Question='Group','Group Productivity',

If (Question='Self','Self Productivity',' ')))

Highlighted
Not applicable

Hi Sunny,

There's about 10 or 11 questions all listed in the Question field.  Two of which, are Self: Productivity' and 'Group: Productivity'.  So the user can select both of them to get stats related to just those two questions.  I'm hoping that makes it clearer.

Thanks,

Tim

Highlighted

I think looking at the data will be more helpful. I am still having trouble understanding what you are trying to do.

Highlighted
Not applicable

Kush,

That works for Self Productivity and Group Productivity, but Total Productivity doesn't display when both are selected.  Any suggestions?

Thanks,

Tim

Highlighted

May be this:

If(SubStringCount(Concat(DISTINCT Question, '|'), 'Group') = 1 and SubStringCount(Concat(DISTINCT Question, '|'), 'Self') = 1, 'Total Productivity', If(Question = 'Group', 'Group Productivity', If(Question = 'Self', 'Self Productivity', ' ')))

Highlighted
MVP
MVP

try this

=If(GetFieldSelections(Question)='Group, Self','Total Productivity',

If(GetFieldSelections(Question)='Group','Group Productivity',

If (GetFieldSelections(Question)='Self','Self Productivity',' ')))

Highlighted
Not applicable

Here's a sample of the data, if that helps:

  

About the sameGroup: ProductivityAsia
About the sameGroup: ProductivityAsia
More ProductiveGroup: ProductivityAsia
More ProductiveGroup: ProductivityAustralia / NZ
About the sameGroup: ProductivityUS / Canada
Less ProductiveGroup: ProductivityUS / Canada
Less ProductiveGroup: ProductivityAustralia / NZ
About the sameGroup: ProductivityAustralia / NZ
About the sameGroup: ProductivityUS / Canada
More ProductiveSelf: ProductivityAsia
Less ProductiveSelf: ProductivityAsia
About the sameSelf: ProductivityAsia
More ProductiveSelf: ProductivityAsia
Less ProductiveSelf: ProductivityAsia
About the sameSelf: ProductivityAsia
More ProductiveSelf: ProductivityLatin America
Less ProductiveSelf: ProductivityLatin America
About the sameSelf: ProductivityLatin America
About the sameSelf: ProductivityUS / Canada
Highlighted
Not applicable

Kush,

This works, except for one minor detail.  I have a OnActivateSheet trigger that automatically sets Question to be the two values, Self and Group.  Your IF statement works if I manually select Self, Group or Both, but it doesn't work when both are automatically selected by the trigger.  If this is as close as we can get, then so be it, but I didn't know if you (or anybody else) has ever seen something like this.

Thanks,

Tim