Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Dimension: Union of 2 Columns

I'd like to get the percentage of something happening based on two dimensions.

For example, I a table looked like this:

FruitA             FruitB            Result

Apples           Oranges          1

Bananas         Pears             1

Pears             Apples            0

My desired result would look like this

Dimension      Measure

Apples              50%

Oranges           100%

Bananas           100%

Pears                50%

----------------------------------------------

If it helps I've worked out the percentage of something happening based on one column:

measure  = (sum(Result)/count(total <FruitA> Won))*100

dimension = FruitA

This returns a result of:

Dimension      Measure

Apples               100%

Bananas             100%

Pears                   0%

1 Solution

Accepted Solutions
undergrinder
Specialist II
Specialist II

Hi Stephen,

Kaushik thought as concatenate not the fields, but the columns.

The script look like that:

     Concatenated_fruits:

          Load

               FruitA as Fruit

              ,Result

          From/Resident YourTable;

     Load

             FruitB as Fruit

             ,Result

     From/Resident YourTable;

G.

View solution in original post

6 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Stephen,

You will have to concatenate them and make one dimension in script, in order to achieve this.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Hi Kaushik,

Thanks for your reply, however I don't understand your answer - If I were to concatenate the 1st row in the sample table the result would be "ApplesOranges"     1  - this isn't the desired result. Or am I misinterpreted your answer?

Kind Regards,

Stephen

undergrinder
Specialist II
Specialist II

Hi Stephen,

Kaushik thought as concatenate not the fields, but the columns.

The script look like that:

     Concatenated_fruits:

          Load

               FruitA as Fruit

              ,Result

          From/Resident YourTable;

     Load

             FruitB as Fruit

             ,Result

     From/Resident YourTable;

G.

undergrinder
Specialist II
Specialist II

If you the combination and order of FruitA and FruitB matters, than you can concatenated the columns, as you mentioned ("Apples|Oranges" rather than "ApplesOranges"), calculate the percentage, afterwhile arrange the columns, with the manner in my and Kaushik previus comment.

G.

reddy-s
Master II
Master II

Hi Stephen,

Concatenation works the same as Union in Qlik. So if you want to union two tables you can make use of hte concatenate function to do so.

Thanks,

Sangram.

Not applicable
Author

Thanks Guys - that worked perfectly.