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: 
evansabres
Specialist
Specialist

Variable Expression If Statement

I have a field called [Day Part] where the values are 1, 2, 3, 4, etc.

I want to create a variable called vName that picks the values when [Day Part] = 11, 12, 13, 14, 15, 16, 17

4 Replies
Digvijay_Singh

Can you explain more, you want one or multiple variable? In script while loading [Day Part]?

vishsaggi
Champion III
Champion III

May be try this in your variable like

If values are strings put them in quotes.

vName = Concat(DISTINCT Pick(Match([Day part], 11, 12, 13, 14, 15, 16), 'Value1', 'Value2', 'Value3', 'Value4', 'Value5'), '|')

tresesco
MVP
MVP

If you want the variable to have assigned value (single) only when the [Day Part] would be selected in that range, you could simply try like:


vName= If([Day Part]>10 and [Day Part]<17, [Day Part])

If you want to consider multiple values in-scope as well, may try like:


vName= Concat( Distinct If([Day Part]>10 and [Day Part]<17, [Day Part]) , ',' )                          // comma separated values

evansabres
Specialist
Specialist
Author

I think this is probably the right answer, but I have some missteps.

Let me start with my ultimate goal. I want to have a current selections box. Currently, I have a button that says 'Lunch,' which is equal to when [Day Part] = 11, 12, 13, 14, 15, 16.

I get the field [Day Part] via a transformation in my script:

     [Business Hour] AS Time,

     Hour([Business Hour]) AS [Day Part],

Time shows as 11:00 AM, 12:00 PM, etc.

Day Part shows as 11, 12, 13, etc/

So, currently, when a user clicks the 'Lunch' button, the current selections box shows [Day Part] (11|12|13|14|15|16)

I am trying to have the current selections box show 'Lunch'. Is there a better methodology to do this?