Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
ZoeM
Specialist
Specialist

Show/Hide Column Fields based on Selection in List Box - Straight Table

Hello Community.

I would like to enable a condition in the expression tab for a few columns to only show when they are selected from the list box.

So in the example attached, I have a total column which will show all the time. But I would like for Washington, Alabama, and Arizona to show only if they are selected by the user from the available list box. and the user can choose to select a variety of  of states accordingly i.e. can choose to see only Washington and Arizona or Alabama and Arizona etc. 

How would I write that conditional expression?

Thanks in advance. 

Labels (2)
1 Solution

Accepted Solutions
jwjackso
Specialist III
Specialist III

I do something similar so that the users can create a custom table to export.  I put this in the expression's conditional test.

 

If(SubstringCount(Concat(distinct state_name,'|'),'|') >= 0 and SubstringCount(Concat(distinct state_name,'|'),'|') <= 51 and GetSelectedCount(state_name) > 0,
If(SubStringCount(Concat(distinct state_name,'|'),'Washington') = 1,1,0),
0)

View solution in original post

4 Replies
jwjackso
Specialist III
Specialist III

I do something similar so that the users can create a custom table to export.  I put this in the expression's conditional test.

 

If(SubstringCount(Concat(distinct state_name,'|'),'|') >= 0 and SubstringCount(Concat(distinct state_name,'|'),'|') <= 51 and GetSelectedCount(state_name) > 0,
If(SubStringCount(Concat(distinct state_name,'|'),'Washington') = 1,1,0),
0)

ZoeM
Specialist
Specialist
Author

This is excellent!

So let me throw you in a loop here for a second. Say we had two states that are very similar?

Say I have Washington(the State) and then there is Washington D.C? 

When I plugged in your expression (which works wonderfully by the way), I am running into the issue of where my similar fields are being shown simultaneously and only want the unique one.

jwjackso
Specialist III
Specialist III

In my application, I created an inline table like below.  I dsiplay the Rfield in the filter and the conditional statement is matching on the RFieldID.  Washington would match on A49 and Washington D.C. would match on A53.

ReportField:
load * inline [
Rfield,RFieldID
Alabama,A01
Alaska,A02
Arizona,A03
Arkansas,A04
California,A05
Colorado,A06
Connecticut,A07
Delaware,A08
District of Columbia,A09
Florida,A10
Georgia,A11
Hawaii,A12
Idaho,A13
Illinois,A14
Indiana,A15
Iowa,A16
Kansas,A17
Kentucky,A18
Louisiana,A19
Maine,A20
Maryland,A21
Massachusetts,A22
Michigan,A23
Minnesota,A24
Mississippi,A25
Missouri,A26
Montana,A27
Nebraska,A28
Nevada,A29
New Hampshire,A30
New Jersey,A31
New Mexico,A32
New York,A33
North Carolina,A34
North Dakota,A35
Ohio,A36
Oklahoma,A37
Oregon,A38
Pennsylvania,A39
Puerto Rico,A40
Rhode Island,A41
South Carolina,A42
South Dakota,A43
Tennessee,A44
Texas,A45
Utah,A46
Vermont,A47
Virginia,A48
Washington,A49
West Virginia,A50
Wisconsin,A51
Wyoming,A52
Washington D.C.,A53
];

ZoeM
Specialist
Specialist
Author

Yea unfortunately I cant make edits in the script. 

 

Thanks though for your help. Let me work off of what you have provided and see if I can figure out how to separate the identical.