Topic: Gauge needs to change based on amount claimed,

I like this gauge posted sometime ago , but I would like the gauge to display percentage results based on the claims and not based on record count .per employee. Link is given below.


https://www.dropbox.com/t/i69CVm3Y2gNBqp2g


Help will be highly appreciated.

Thanks a bunch.

Re: Gauge needs to change based on amount claimed,

This is a weird project. What exactly do you want to get as a percentage? Do you want to know which percentage of the allocated budget has been taken by employees or do you want to summarize the percentage of expenses by employees? You may need a reference for the 100%.
Otherwise, it seems this project calculate the percentage of expenses by employees and the reference is just the sum of all expenses which is... weird!! When you click on each employee, there is personal percentage... to compare with what?

It seems that the result in Label2 stating that the total of claims is equal to 100% is correct. What are you looking for actually?

Re: Gauge needs to change based on amount claimed,

HI,

I'd like to summarize the percentage of expenses by employees please

Re: Gauge needs to change based on amount claimed,

Which version of MVDB are you using?

5 (edited by tcoton 2020-07-23 23:57:57)

Re: Gauge needs to change based on amount claimed,

I could get something interesting by changing this in the script:

procedure start_kpi;
begin
  form1.label2.caption := 'TOTAL CLAIMS: ' + floattostr(sqlexecute('select SUM(claimvalue) from expenses')) + ' £ (100%)';
end;

procedure employee_kpi;
var  vbar: int;
var vclaimno: currency;
begin
  vbar := sqlexecute('select SUM(claimvalue) from expenses where id_employee =' +floattostr(form1.tablegrid1.dbitemid))/sqlexecute('select SUM(claimvalue) from expenses')*100.0;
 // form1.panel2.width := 10;
  form1.panel2.width := form1.panel2.width + (vbar * 4);
  vclaimno := sqlexecute('select SUM(claimvalue) from expenses where id_employee =' +floattostr(form1.tablegrid1.dbitemid));
  form1.label1.caption := floattostr(vclaimno) + ' £  (' + floattostr(vbar)+ '%)';
end;

Problem is, I don't know yet how to get a percentage with decimals in Delphi so all percentages are rounded hence the 0% for the guy who only has 4,99£ because the true result is 0,14% due to this line where I cannot get an extended value for the panel2.width

form1.panel2.width := form1.panel2.width + (vbar * 4);

Edit:

I could get a percentage with decimals using this :

var  vbar: currency; //instead of var bar: int;

form1.panel2.width := form1.panel2.width + round(vbar * 4);

But, I don't know how to limit the number of decimals to 2 only for the percentage .

Re: Gauge needs to change based on amount claimed,

Thanks alot I'll give it  a try and let you know

Re: Gauge needs to change based on amount claimed,

Thanks Tcoton,

it worked well with the code below:

procedure start_kpi;
begin
  form1.label2.caption := 'TOTAL CLAIMS: ' + floattostr(sqlexecute('select SUM(claimvalue) from expenses')) + ' £ (100%)';
end;

procedure employee_kpi;
var  vbar, vclaimno: integer;
begin
  vbar := sqlexecute('select SUM(claimvalue) from expenses where id_employee =' +floattostr(form1.tablegrid1.dbitemid))/sqlexecute('select SUM(claimvalue) from expenses')*100;
form1.panel2.width := 10;
  form1.panel2.width := form1.panel2.width + (vbar * 4);
  vclaimno := sqlexecute('select SUM(claimvalue) from expenses where id_employee =' +floattostr(form1.tablegrid1.dbitemid));
  form1.label1.caption := floattostr(vclaimno) + ' £  (' + floattostr(vbar)+ '%)';
end;

Re: Gauge needs to change based on amount claimed,

So you don't mind not having the decimals in the percentages and the expense sums then.