Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Pick/Match Not Working

Hello Community. Do you see anything wrong with this expression, which is part of a straight table in QlikView 11.2? This builds label header text on an expression.

=pick(alt(match(Only(_DemandDays), 30, 60, 90, 180, 360, 365) + 1, 0),

'Mixed Demand',

'Demand 30 Days',

'Demand 60 Days',

'Demand 90 Days',

'Demand 180 Days',

'Demand 365 Days',

'Demand 365 Days')

When the selections include different demand days, I would expect "Mixed Demand" to appear in the label. Instead, a hyphen appears. However, if I isolate the expression, alt(match(Only(_DemandDays), 30, 60, 90, 180, 360, 365) + 1, 0), it correctly returns 0 under these circumstances. By itself, match(Only(_DemandDays), 30, 60, 90, 180, 360, 365) + 1 returns NULL -- hence the need to wrap the alt() function around it. The other labels are displayed correctly when the Only() function returns a value.

I can't easily provide an example right now. I'm just wondering if there's anything glaringly wrong with the expression. Thank you for looking.

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Or maybe

=pick(alt(match(Only(_DemandDays), 30, 60, 90, 180, 360, 365) , 0)+1,

'Mixed Demand',

'Demand 30 Days',

'Demand 60 Days',

'Demand 90 Days',

'Demand 180 Days',

'Demand 365 Days',

'Demand 365 Days')

View solution in original post

6 Replies
sunny_talwar

Not sure why you need Alt?

=Alt(Pick(Match(Only(_DemandDays), 30, 60, 90, 180, 360, 365),

'Demand 30 Days',

'Demand 60 Days',

'Demand 90 Days',

'Demand 180 Days',

'Demand 365 Days',

'Demand 365 Days'),

'Mixed Demand')

Not applicable
Author

I explained that. Anyway, your example returns "Mixed Demand" for every selection.

sunny_talwar

This seems to be working

=If(Len(Trim(Pick(Match(Only(DemandDays), 30, 60, 90, 180, 360, 365),

'Demand 30 Days',

'Demand 60 Days',

'Demand 90 Days',

'Demand 180 Days',

'Demand 365 Days',

'Demand 365 Days'))) = 0, 'Mixed Demand',

Pick(Match(Only(DemandDays), 30, 60, 90, 180, 360, 365),

'Demand 30 Days',

'Demand 60 Days',

'Demand 90 Days',

'Demand 180 Days',

'Demand 365 Days',

'Demand 365 Days'))

swuehl
MVP
MVP

Or maybe

=pick(alt(match(Only(_DemandDays), 30, 60, 90, 180, 360, 365) , 0)+1,

'Mixed Demand',

'Demand 30 Days',

'Demand 60 Days',

'Demand 90 Days',

'Demand 180 Days',

'Demand 365 Days',

'Demand 365 Days')

sunny_talwar

This can be further reduced to this:

=If(Len(Trim(DemandDays)) = 0, 'Mixed Demand',

Pick(Match(Only(DemandDays), 30, 60, 90, 180, 360, 365),

'Demand 30 Days',

'Demand 60 Days',

'Demand 90 Days',

'Demand 180 Days',

'Demand 365 Days',

'Demand 365 Days'))

Not applicable
Author

Thank you. That works splendidly.