Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Two calculations in Single Dimension for a Pie Chart

I am trying to create a Pie Chart which should give me two sections-Blocked and Not Blocked based on the following two conditions

Condition 1:

If([Lifecycle1]>0,'Blocked','Not Blocked')

Condition 2:

If([Lifecycle2]>0,'Blocked','Not Blocked')

Here is what I am doing to get this done. I have created a Dimension with the following expression inside it.

=if([Lifecycle1]>0
OR
[Lifecycle2]>0,'Blocked','Not Blocked')

And in the Expressions, I am using

Count(Distinct([Application ID]))

The pie chart gives me two sections with Blocked and Not Blocked. When I select the Not Blocked, the whole pie changes to Not Blocked, which is fine. But when I select Blocked section of the pie, it returns both Blocked and Not Blocked. What is the issue

1 Solution

Accepted Solutions
swuehl
MVP
MVP

If you click on 'Blocked' section, you are essentially selecting values in fields Lifecycle1 and Lifecycle2.

Without knowing your data and model, it's hard to tell why these selections result in 'Blocked' section still showing up, but potentially this may happen when the selected Lifecycle values allow this.

I assume you want a selection on field Application ID instead, use this as calculated dimension:

=Aggr(if([Lifecycle1]>0 OR [Lifecycle2]>0,'Blocked','Not Blocked'), [Application ID])

View solution in original post

10 Replies
swuehl
MVP
MVP

If you click on 'Blocked' section, you are essentially selecting values in fields Lifecycle1 and Lifecycle2.

Without knowing your data and model, it's hard to tell why these selections result in 'Blocked' section still showing up, but potentially this may happen when the selected Lifecycle values allow this.

I assume you want a selection on field Application ID instead, use this as calculated dimension:

=Aggr(if([Lifecycle1]>0 OR [Lifecycle2]>0,'Blocked','Not Blocked'), [Application ID])

Not applicable
Author

Hi,Thanks Swuehl. I can't post more details here due to Privacy. Anyway, the given expression solves my issue but when I select the Blocked Section, the color of the pie changes to the one that of Not Blocked, but at least it doesn't show two sections. Any idea what's causing the color issue?

swuehl
MVP
MVP

If I understood correctly, I think that's QV standard (if only one section is shown, the color #1 of the palette will be used, regardless of the calculated dimension value).

Try the option 'persistent colors' on color tab of pie chart properties.

Not applicable
Author

Selecting and De-selecting it is not brining any change to the pie chart colors, Swuehl. When no section is selected, the Blocked section is Red and the Not Blocked is Green. But when I select Blocked, the whole pie chart turns to red. When I select the Not Blocked section, the whole pie turns to Red, instead of Green.

swuehl
MVP
MVP

Try a background color attribute expression (on expression tab, open attributes by clicking the small plus sign):

=Aggr(if([Lifecycle1]>0 OR [Lifecycle2]>0, LightRed(), Lightgreen() ), [Application ID])

Not applicable
Author

Tried it. Still not working. The Colors tab in the Object properties lists the colors in the order of the conditions.

For example, in Data Appearance, if the Colors 1-6 has Red and Yellow in order, whenever the first condition is true (in my case Blocked) in the expression, it automatically uses the color Red. Similarly, if the second condition is true (in my case Not Blocked), it will take Yellow.

I still don't understand why it is not following the color scheme. Although the count is correct, it doesn't make sense if I select Blocked and I see Red and when I select Not Blocked, I see Red again.

swuehl
MVP
MVP

Are you sure you are using the background color attribute expresssions? It shouldn't follow the palette colors then.

Not applicable
Author

Yeah, I did the expression inside the Dimension's Background Color Attribute.

swuehl
MVP
MVP

Hm, I think I've mentioned the expression tab...