Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Make your voice heard! Participate in the 2020 Wisdom of Crowds® Survey. BEGIN SURVEY
Highlighted
evansabres
Valued Contributor

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
Highlighted
Digvijay_Singh
Honored Contributor III

Re: Variable Expression If Statement

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

Highlighted
vishsaggi
Esteemed Contributor III

Re: Variable Expression If Statement

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'), '|')

Highlighted
MVP
MVP

Re: Variable Expression If Statement

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

Highlighted
evansabres
Valued Contributor

Re: Variable Expression If Statement

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?