Run time calculations for linear or radial gauge

by MohamedGaafar » Tue Mar 15, 2016 2:18 am

Hi,
I have a sales pipeline list with a calculated category column having these values (Cold, Warm, Hot, Won, Lost). I tried to build a linear or radial gauge to calculate the win rate (total won/total pipeline items)*100.

I tried following your example for doing run time calculations in sales distribution chart on the sales dashboard demo page: http://www.spchart.com/demo/sales-dashboard/config

However i couldn't get it to work out for me on a linear or radial gauge.
Appreciate your help.
User avatar
MohamedGaafar
 
Posts: 22
Joined: Sat Jan 23, 2016 12:17 pm

by Rostislav » Tue Mar 15, 2016 10:57 am

Hi,

I would propose:

1. Create a calculated column that would output 1 for "Won" entities, otherwise 0
2. Go to Data Source -> Aggregation
a. enter anything that's not an existing field name into Group by
b. add an aggregated value: count = count of ID
c. add an aggregated value: sumwon = sum of the calculated column from #1
3. Go to Data Source -> Advanced, add the following line of code to the aggergationSuccess function:
Code: Select all
handlers.aggregationSuccess = function(data, logger) {
   data.groups[0].winRate = data.groups[0].sumwon/data.groups[0].count * 100;
   return true;
}

4. Click Process
5. Select winRate as the value for the chart.
User avatar
Rostislav
 
Posts: 61
Joined: Fri Oct 09, 2015 10:51 am

by MohamedGaafar » Wed Mar 16, 2016 5:20 pm

Thanks a lot for your support, your solution worked out for me.
User avatar
MohamedGaafar
 
Posts: 22
Joined: Sat Jan 23, 2016 12:17 pm

by wparks77 » Sat Dec 03, 2016 8:20 pm

Hello Rostislav,

I have followed your example and everything seems to work, however my % should be ~20.5% and I am showing a tad bit above 40% for this particular view.

For this view:

Total Won (1) = 51 records
Total Items (0&1) = 248 records

Any advice would be greatly appreciated.
Attachments
chart_export.zip
Zipped due to .txt type.
(1.19 KiB) Downloaded 6 times
wparks77
 
Posts: 13
Joined: Sat Dec 03, 2016 7:54 pm

by Dmitry Kozlov » Mon Dec 05, 2016 9:13 am

Hi,
Could you also provide a template of the source list with its content (list settings -> save this list as template -> tick Include Content).
User avatar
Dmitry Kozlov
 
Posts: 129
Joined: Wed Nov 12, 2014 3:24 pm

by wparks77 » Mon Dec 05, 2016 5:15 pm

Yes sir and thank you very much. Please see the attached.
Attachments
Bid Log.zip
Zipped due to STP extension.
(199.12 KiB) Downloaded 6 times
wparks77
 
Posts: 13
Joined: Sat Dec 03, 2016 7:54 pm

by YuriyMedvedev » Tue Dec 06, 2016 12:43 pm

Hi! Replace your handlers.aggregationSuccess with this code and remove any extra-fields in DS -> Aggregation:
Code: Select all
handlers.aggregationSuccess = function(data, logger) {
 
   var count = data.items.reduce(
     function(count, curr){
       return count + (curr.Status == "Won"); 
         }, 0);
   data.groups[0].winRate = count/data.items.length;
  return true;
}


After that choose in Dashboard -> Chart "winRate" in "Value"
YuriyMedvedev
 
Posts: 14
Joined: Mon Sep 26, 2016 3:05 pm

by wparks77 » Tue Dec 06, 2016 8:01 pm

Works beautifully. I want to thank you and your team for the excellent customer support.
wparks77
 
Posts: 13
Joined: Sat Dec 03, 2016 7:54 pm


Return to Dashboard Designer for SharePoint 2013