Skip to main content
Announcements
The way to achieve your own success is the willingness to help somebody else. Go for it!
cancel
Showing results for
Search instead for
Did you mean:
Contributor II

## Alternate Dimension- Three nested functions

Hello,

Last week I started my first job IT job as trainee QV developer. My first task is to maintain a QVW.

There is button in the QVW that I know what is doing (show results by Continent and Country) but I could not get the logic of the expression competently:

=Pick(2 - Mod(Match(vLevel, 'Country', 'Continent') + 1, 2), 'Country', 'Continent')

I already know what each of the 3 function do (when they are separated), but I am getting confused with that nested function between the mod and the match.

Could someone please explain me what going on between the Mod and the Match?

Thank you for your help!

1 Solution

Accepted Solutions

The match function returns an integer: 0, 1 or 2. The Mod function takes the modulus 2 of that number after 1 is added to it. So it returns 0 or 1. The pick function the picks the first (2 - 1) or second (2 - 0) value in the list of 'Country', 'Continent'

It's an unnecessarily complicated expression. I find this clearer: =If(vLevel='Country','Continent','Country')

talk is cheap, supply exceeds demand
8 Replies
MVP

It seems that when vLevel = Country, then the expression will output Continent. When vLevel =Continent, then the expression will output Country. This seems like a very complicated solution to a simple problem. Can you try if the below expression gives the same output as the one you have provided?

=Pick(Match(vLevel, 'Country', 'Continent'), 'Continent', 'Country')

Partner Ambassador/MVP

Here is my interpretation of the results.

If vLevel='Country', then pick 'Continent'.

If vlevel='Continent', then pick 'Country'

if vLevel <> 'Continent' OR 'Country', then pick 'Country'

If I understand the meaning correctly, then I think it's more complex then necessary. I would have written it like this:

=Pick(Match(vLevel, 'Country', 'Continent') + 1), 'Country', 'Continent', 'Country')

-Rob

http://masterssummit.com

http://qlikviewcookbook.com

The match function returns an integer: 0, 1 or 2. The Mod function takes the modulus 2 of that number after 1 is added to it. So it returns 0 or 1. The pick function the picks the first (2 - 1) or second (2 - 0) value in the list of 'Country', 'Continent'

It's an unnecessarily complicated expression. I find this clearer: =If(vLevel='Country','Continent','Country')

talk is cheap, supply exceeds demand
Contributor II
Author

Hi,

I had the same tough and I did the exact same thing. But the button didnt work.

If you put it in the text box it works, but not as an action.

Contributor II
Author

Thank you for your help,

I am going to try your solution to check the result.

Contributor II
Author

Thank you for your reply and explanation, I am getting even closer to the logic of it.

I will also try the alternative solution that you sent me.

MVP

Check out the attached qvw, both the buttons are doing the same thing.

Contributor II
Author

Thanks for those, I will check and compare with mine and find out why it didnt work (my one).

Community Browser