Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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,

7 Replies
Anil_Babu_Samineni

Condition seems ok, Can you make it in sample?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
rubenmarin

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()))))

Anonymous
Not applicable
Author

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.

Anonymous
Not applicable
Author

Sorry, I did not understand your point.

rubenmarin

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?

Anonymous
Not applicable
Author

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

rubenmarin

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.

Uploading a Sample

Which values shows the table and which values you expected?