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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
simoj89
Contributor II
Contributor II

Aggregation of 50% of a dimension into another

Hi! 

I'm in this situation:

Type | Count element

A | 10

B | 15

C | 20

D | 5

From this table i need to obtain another table (and relative pie chart) where Type C elements are included 50% into A and the other 50% into B. So something like that:

A+50%C | 20

B+50%C | 25

D | 5

How i can reach this result?

Thanks! 

 

Labels (2)
1 Solution

Accepted Solutions
Kushal_Chawda

@simoj89  try below

=if(match(Type,'A','B'),Count({<Type-={"C"}>}Code)+ (Count(total {<Type={"C"}>}Code)*0.5),
Count({<Type-={"C"}>}Code))

Screenshot 2020-10-20 165838.png

View solution in original post

6 Replies
Taoufiq_Zarra

@simoj89  like ?

in dimension :

=if(Type<>'C',Type)

and Supress when value is null

in expression:

sum([Count element])+sum({<Type={'C'}>} total [Count element])*0.5

 

output:

Capture.PNG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Kushal_Chawda

@simoj89  what is the expression used for count of element?

simoj89
Contributor II
Contributor II
Author

@Kushal_Chawda @Taoufiq_Zarra 

Maybe i've made a bit of confusion with the "Count Element", it isn't a dimension,  is a real count measure.

The starting table is like:

Code | Type | ecc ecc 

001 | A | ecc ecc

002 | A | ecc ecc

003 | A | ecc ecc

004 | A | ecc ecc

005 | B | ecc ecc

006 | B | ecc ecc

007 | B | ecc ecc

008 | C | ecc ecc

009 | C | ecc ecc

010 | D | ecc ecc

011 | D | ecc ecc

012 | D | ecc ecc

In qlik i've one KPI that shows all the 4 Types with a conut(code) measure.

In anothere KPI i need to show only Types A,B and D and the count(code) of Type C must be considered half in Type A and half in Type B.

So the output i expect is

Type | Count(code)

A | 5 (equals:  4 from Count(Type A, code) + 1 from Count(Type C,code)/2)

B | 4 (equals: 3 from Count(Type B, code) + 1 from Count(Type C,code)/2)

D | 3 (equals: 3 from Count(Type D, code))

Hope is better explained now!

Kushal_Chawda

@simoj89  try below

=if(match(Type,'A','B'),Count({<Type-={"C"}>}Code)+ (Count(total {<Type={"C"}>}Code)*0.5),
Count({<Type-={"C"}>}Code))

Screenshot 2020-10-20 165838.png

Kushal_Chawda

@simoj89  just a follow up question.  If count is odd number like "3" then how would you count that as 50% of it will be 1.5 , so would you like to do rounding after addition?

simoj89
Contributor II
Contributor II
Author

Yes, i've put the round() function in the measure expression and works perfect!