Qlik Community

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Customer & Partners, DEC. 9, 11 AM ET: Qlik Product & Strategy Roadmap Session: Data Analytics REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
juriengroot
Contributor III
Contributor III

Default value for pick match

Hi,

I am using a pick and match formula with a dimension (not a variable) and I'd like to show a default value if no value is picked.

$(=Pick(Match((Grouping1),'Option1',

'Option2')

,'[Option1]'

,'[Option2]'

))

I thought of something like:

if(Count(Grouping1)=1, $(=Pick(Match((Grouping1),'Option1',

'Option2')

,'[Option1]'

,'[Option2]'

)),Option1)

Anyone knows the right syntax for it?

1 Solution

Accepted Solutions
sunny_talwar

How about this:

$(=if(Count(DISTINCT Grouping1) = 1, Pick(Match((Grouping1),'Option1',

'Option2')

,'[Option1]'

,'[Option2]'

), '[Option1]'))

or

$(=if(GetSelectedCount(Grouping1) = 1, Pick(Match((Grouping1),'Option1',

'Option2')

,'[Option1]'

,'[Option2]'

), '[Option1]'))

View solution in original post

11 Replies
sunny_talwar

May be this

$(=Pick(Match((Grouping1),'Option1',

'Option2') + 1

,'[Option1]'

,'[Option1]'

,'[Option2]'

))

juriengroot
Contributor III
Contributor III
Author

Hi Sunny,

Unfortunately it doesn't seem to work.

sunny_talwar

So, let me clarify this. The expression was working before you introduced this new requirement? So, essentially this was working?

$(=Pick(Match((Grouping1),'Option1',

'Option2')

,'[Option1]'

,'[Option2]'

))

juriengroot
Contributor III
Contributor III
Author

That is indeed working, but only once I select Option 1 or 2 in my dropdown selection box.

Without a selection it is showing nothing. I want it to show option 1 by default as well.

rahulpawarb
Specialist III
Specialist III

Hello Jurien,

Trust that you are doing good!

Could you please try something like below?

$(=If(IsNull(Pick(Match((Grouping1),'Option1','Option2'),'[Option1]','[Option2]')),

      'Default',

      Pick(Match((Grouping1),'Option1','Option2'),'[Option1]','[Option2]')

      )

  )

Hope this will help.

Regards!

Rahul

sunny_talwar

How about this:

$(=if(Count(DISTINCT Grouping1) = 1, Pick(Match((Grouping1),'Option1',

'Option2')

,'[Option1]'

,'[Option2]'

), '[Option1]'))

or

$(=if(GetSelectedCount(Grouping1) = 1, Pick(Match((Grouping1),'Option1',

'Option2')

,'[Option1]'

,'[Option2]'

), '[Option1]'))

View solution in original post

marcus_sommer
MVP & Luminary
MVP & Luminary

With a small tweak Sunny's approach should work:

$(=Pick(rangesum(Match((Grouping1),'Option1',

'Option2'), 1)

,'[Option1]'

,'[Option1]'

,'[Option2]'

))

to return the default-value of 1 even if Grouping1 returned NULL because there are more as one value possible and no aggregation is used.

- Marcus

juriengroot
Contributor III
Contributor III
Author

I used the second option and it worked!

juriengroot
Contributor III
Contributor III
Author

This doesn't seem to work, but I used Sunny's 2nd suggestion.