# Qlik Sense App Development

Contributor

## Change color by expression for a scatter plot bubbles?

I want to change the color of my scatter plot bubbles based on their fractile(based on sales). I am using the following pece of code in expression:

if ([Total Sale Quantity]<=Fractile(total [Total Sale Quantity],0.20), Red(),

if ([Total Sale Quantity]<=Fractile(total [Total Sale Quantity],0.40), Blue(),

if ([Total Sale Quantity]<=Fractile(total [Total Sale Quantity],0.60), Green(),

if ([Total Sale Quantity]<=Fractile(total [Total Sale Quantity],0.80), Yellow(),

LightRed()))))

But, it is giving me lightRed fr all the bubbles. Please guide me where I am going wrong.

Thanks,

Best Regards,

Tags (3)
7 Replies
MVP

## Re: Change color by expression for a scatter plot bubbles?

Condition seems ok, Can you make it in sample?

MVP

## Re: Change color by expression for a scatter plot bubbles?

Hi Rahul, the first part of the comparison is only sales, not the fractile, maybe you are looking for?:

if (Fractile([Total Sale Quantity],0.2)<=Fractile(total [Total Sale Quantity],0.20), Red(),

if (Fractile([Total Sale Quantity],0.40)<=Fractile(total [Total Sale Quantity],0.40), Blue(),

if (Fractile([Total Sale Quantity],0.60)<=Fractile(total [Total Sale Quantity],0.60), Green(),

if (Fractile([Total Sale Quantity],0.80)<=Fractile(total [Total Sale Quantity],0.80), Yellow(),

LightRed()))))

Or there is more than one value for total Sale and needs to be aggregated, ie:

if (Sum([Total Sale Quantity])<=Fractile(total [Total Sale Quantity],0.20), Red(),

if (Sum([Total Sale Quantity])<=Fractile(total [Total Sale Quantity],0.40), Blue(),

if (Sum([Total Sale Quantity])<=Fractile(total [Total Sale Quantity],0.60), Green(),

if (Sum([Total Sale Quantity])<=Fractile(total [Total Sale Quantity],0.80), Yellow(),

LightRed()))))

Contributor

## Re: Change color by expression for a scatter plot bubbles?

No, my aim is to color the bubbles based on the sales. If the sales are in the 20 percentile then red and so on.

Contributor

## Re: Change color by expression for a scatter plot bubbles?

Sorry, I did not understand your point.

MVP

## Re: Change color by expression for a scatter plot bubbles?

But each dot has only one value for [Total Sale Quantity]? Ie, if there is a value for each month and you select only a year there will be 12 different values for each dot (one for each month) and you need to do some aggregation to return only one value for each dot.

You can copy the chart and transform it to a table, make different expressions with each part of the expression to check the values:

Dimensions:

- The current dimensions of the bubble chart

Expressions:

- [Total Sale Quantity]

- Fractile(total [Total Sale Quantity],0.20)

- Fractile(total [Total Sale Quantity],0.40)

This table shows the values you expected?

Contributor

## Re: Change color by expression for a scatter plot bubbles?

No, actually the table is also not showing the correct values. It is also showing me the last condition.

MVP

## Re: Change color by expression for a scatter plot bubbles?

It will be difficult to reach a solution without an image or a sample that can give a tip on how is your data model and what's happening.