Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Pie Chart Aggregation

I'm trying to create a pie chart that looks like this:

pie.PNG

But I'm confused as to how I can accomplish this. Essentially it shows which users were active and which weren't. So "Activity" would be the count of all users that have any activity. "No Activity" the sum of all users who have no activity at all. I don't quite understand how I have to define the dimension/measurement in this case.

There's two tables, one with the user names and one with the activities. Simplified, the data looks like this:

database.PNG

Attached is also an example app. Thanks in advance.

1 Solution

Accepted Solutions
OmarBenSalem

In that case, you have this:

Capture.PNG

Active is 5? (the 5 dates?) or 3? the 3 users 1,2 and 3?

if we'll count the 5 dates:

Count({<Date={"=Count( UserName)>0"}>}Date)


or just count(Date)

=>which means, count the Date when the Date has a userName (count(user)>0)

if we'll count the 3 users:

Count({<UserName={"=Count( Date)>0"}>}UserName)


=>which means, count UserName when Users have a date

Now, inactive are 3; 3 users without a date (count(date)=0 per user)

Count({<UserName={"=Count( Date)=0"}>}UserName)

=>which means, count userName when the UserName does not have a Date

In the pie chart, the measure would be:

If(ValueList('Active','Inactive') ='Active',Count({<Date={"=Count( UserName)>0"}>}Date),

  if(ValueList('Active','Inactive')='Inactive',Count({<UserName={"=Count( Date)=0"}>}UserName))

)


See the attached app

View solution in original post

7 Replies
OmarBenSalem

Use ValueList.

Let me explain,

suppose your have:

Expression1  : sum of Active users

Expression2: sum of Inactive users

To create your pie chart:

as dimension:

ValueList('Active','Inactive')

as measure:

If(ValueList('Active','Inactive') ='Active',Expression1, if(ValueList('Active','Inactive') ='Inactive',Expression2))

Not applicable
Author

Thanks a lot, that's one step closer to getting to a solution. I'm not quite sure how to count the users that were active/inactive though. I think this has to be done with a set expression, but I may be wrong. The syntax is really weird. This isn't returning correct results, it should've been 50%/50% with my test data, and it ended up being 33.3%/66.7% for some reason:

If(ValueList('Active','Inactive') ='Active',Count(UserName),
   if(ValueList('Active','Inactive')='Inactive',Count( Date={"=Count(Date)>0"}>} UserName ))
)
OmarBenSalem

The app you've shared does not contains any valuable field (only quarter, year, sales); can you share an app with such an information?

Not applicable
Author

My bad, I attached the wrong app - I've updated the question now.

OmarBenSalem

In that case, you have this:

Capture.PNG

Active is 5? (the 5 dates?) or 3? the 3 users 1,2 and 3?

if we'll count the 5 dates:

Count({<Date={"=Count( UserName)>0"}>}Date)


or just count(Date)

=>which means, count the Date when the Date has a userName (count(user)>0)

if we'll count the 3 users:

Count({<UserName={"=Count( Date)>0"}>}UserName)


=>which means, count UserName when Users have a date

Now, inactive are 3; 3 users without a date (count(date)=0 per user)

Count({<UserName={"=Count( Date)=0"}>}UserName)

=>which means, count userName when the UserName does not have a Date

In the pie chart, the measure would be:

If(ValueList('Active','Inactive') ='Active',Count({<Date={"=Count( UserName)>0"}>}Date),

  if(ValueList('Active','Inactive')='Inactive',Count({<UserName={"=Count( Date)=0"}>}UserName))

)


See the attached app

Not applicable
Author

Thanks a bunch! That is working well.

rkpatelqlikview
Creator III
Creator III

Thanks Omar. Its really  helped me a lot. Can we split the pie like below. If possible, How can we?

Thanks in advance.SplitPie.PNG