# Speedometer gauge using calculated columns?

My idea is implement a speedometer gauge at the top of my page that will change dynamically based on the average of a column, what i'm thinking is to use three speedometer images (low/med/high) and have it change based on the average of a specific column.

Is it possible to connect the two? I also understand that there are third-party guages out there, but I don't want to spend any money.

Thanks!

• Can you mark your question as answered, It keeps popping up in the Unanswered list – Danny '365CSI' Engelman Aug 10 '15 at 11:06

Interesting friday evening challenge..

I took a completely weird approach

process every row (when displayed)

store the High, Low , Total and Average value on the body tag

for every row done (they proces async)

calculate the 3 segments (low,medium,high) between the Low Values calculate Average, match with low,medium,high color

and color the Table (4 parentnodes up from the img injected into the calculated column) accordingly

``````="<img src='/_layouts/images/blank.gif'onload=""(function(me,i){var d=document.body;function g(n){return(~~d.getAttribute(n))}function s(n,x){return(d.setAttribute(n,x))}l=g('l');if(i>g('h')){s('h',i)}if(i<l||l==0){s('l',i)}s('t',g('t')"&"+i);s('n',g('n')+1);s('a',g('t')/g('n'));h=g('h');l=g('l');a=g('a');p=(h-l)/3;c='#'+(i<l+p?'9fa':i<h-p?'fda':'fab');me.parentNode.parentNode.parentNode.parentNode.style.backgroundColor=c;})(this,~~"&[ID]&")"">"
``````

Paste this exact line in a calculated column.. SET THE DATATYPE TO NUMBER and replace [ID] with the column you want to average

Disclaimer.. works for me; its totally weird and using datatype=number is an unofficial trick

But I had a great hour on a dull friday evening :-)

You can actually use Christophe's HTML Calculated Column, please have a look at following question:

how to show HTML code in column?

So based on average of a column, you build up your HTML in calculated column to show the image and you put the JavaScript that does the magic to convert that String representation of HTML to actual HTML.