Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
sasukeindra
Contributor II
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
Gysbert_Wassenaar

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

View solution in original post

8 Replies
sunny_talwar

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

rwunderlich
Partner Ambassador/MVP
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

Gysbert_Wassenaar

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
sasukeindra
Contributor II
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. 

sasukeindra
Contributor II
Contributor II
Author

Thank you for your help,

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

sasukeindra
Contributor II
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.

sunny_talwar

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

Capture.PNG

sasukeindra
Contributor II
Contributor II
Author

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