Jump to content

Dynamically calculate % of total after applying marking to linked visualization


Connor Moore

Recommended Posts

I am trying to calculate the percentage of sales a salesman has in a particular city. I have another visualization that I would like to drive this calculation for whichever salesman I select.See example below with problem and commentary following.

Example Data Set

 

 

 

Salesman

City

Amount of Sales

Opportunity (Calculate in Custom Expression)

Market Share (Calculate in Custom Expression)

 

 

 

 

Tim

Chicago

50

400

25%

 

 

Tim

Chicago

50

400

25%

 

 

David

Chicago

300

400

75%

 

 

Kim

New York

600

1000

60%

 

 

Tim

New York

400

1000

40%

 

 

 

 

 

 

 

 

 

 

 

Scatter Plot Visualization

Y-Axis ="Opportunity"

 

Custom Expression = Sum([Amount of Sales]) OVER (All([Axis.Marker]))

 

X-Axis ="Market Share"

 

Custom Expression = Sum([Amount of Sales]) / Sum([Amount of Sales]) OVER (All([Axis.Marker]))

 

Color by = "City"

Marker by = "Salesman"

 

What I want to see when I select Salesman = Tim in driving visualization and hover over City = Chicago data pointin scatter plot:

 

Y-Value (Opportunity) = 400

X-Value (Market Share) = 25%

 

Instead what I see is:

 

Y-Value (Opportunity) = 100

X-Value (Market Share) = 100%

 

As you can see, it only takes the sum of the sales that Tim has and uses that as the Opportunity; neglecting to include the other 300 of sales that David has. Thus when you divide the the numerator (=100) by the denominator (=100) the Market Share = 100%.

It is worth noting that if I do not select anything in my driving visualization (where I would select 1 or more Salesman), the scatter plot correctly displays what I want for all Salesman.

Link to comment
Share on other sites

  • 2 months later...

That is because you have selected to limit data by marking in other visualization. So once you mark any salesman in other visualization, only data related to that salesman will be shown (similar to drill-down functionality). As only Tim's data is flowing in visualization, expressionscalculated would be incorrect.

You can achieve your requirement through the use of data function. You can trigger data function on marking change which will set document property value to salesman marked instead of limiting visualization using marking.

- Remove limit data by marking from scatter plot

- Create data function as mentioned in below article:

You can insert simple script which copies input to output document property

 

op

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...