Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
drunk8gods
Contributor
Contributor

Avg Aggregate Function not working in sankey chart

I am trying to use a sankey visualization that has 3 levels - Channel, State, City.  The measure I will be using is a simple score based 1-100.

When I add the measure calculation to the sankey visualization, the values are in the thousands, when it should be an average between 1-100 for each of the 3 levels.

Here is the code I am using.

avg(aggr(sum(score), Channel,State,City))

An example of the data is as follows:

State - City - Score

NY - NYC - 45

NJ - Trenton - 50

NY - Newburgh - 95

 

Thanks in advance

Labels (1)
3 Replies
drunk8gods
Contributor
Contributor
Author

To be a bit more clear in my request, I'll include a screencap to show what I'm experiencing.

As you can see, the gauges are showing the correct avg scores, but on the sankey, the avg scores are off.

Is there a way to show an avg. score by each level of the sankey?

 

01.png

UncleRiotous
Creator
Creator

I'm seeing the same problem on one of my apps. If we have one chart that sums and one chart that counts then we get the correct figures. If we have a chart that gets the average by dividing the sum by the count we get a completely incorrect result. It's almost like it's working out the average values for the final dimension of the chart and then adding them together.

Does anyone have a solution?

rnorris
Partner - Contributor III
Partner - Contributor III

Hi, don't have a solution yet, but just wanted to point out that it seems like the way the Sankey chart works is whatever you put as the expression, it does a sum of it.

This is explained in the manual as being because it can't split numbers on the left to the right, e.g. in your example above, because Arkansas has a value of 381, despite whatever the values 'should' be on the left, they have to add up to 381.

This is really annoying, because it means that the only thing that's actually accurate in 90% of circumstances where we want to use the Sankey is the size of the flow bars relative to each other, which is only useful at a glance.

Going to keep trying to find a way around it though.

/Edit: Ok, I think I might have it? Possibly? What I've done, is to change everything around so that I'm only using Sum in my Sankey chart expression. I'm not sure if this step is essential, but it certainly made life easier. 

The next thing I did was to change my expression to be:

Sum(x) / count(distinct dimension1) / count(distinct dimension2) / count(distinct dimension3)

This 'seems' to have landed on the right figures, but I'll need to do some further testing to make sure.