1 (edited by borisavljevic 2021-08-25 22:45:53)

Topic: [SOLVED] Need help - stucked. Project with explanation attached.

Hi all,

I'm trying to build database for machine maintence but I'm stucked. I'm still learning, tried everything I know but there is no way for me to find solution for my problem.
Please check attached project and txt file which contains examples and explanation of my problem.

Thanks in advance!

Post's attachments

Attachment icon KPI project example.rar 301.06 kb, 261 downloads since 2020-06-26 

Re: [SOLVED] Need help - stucked. Project with explanation attached.

Hi Vladimir,
I had a quick look at your project and tried to work through your examples.
But I am not clear with Example 3.  In your .txt file, you write for all time dates and for all machine groups, the sum of preventative time is 205 and sum of corrective time is 169 which totals 364.  But the footer total for form1.tablegrid1.column[6] is 456.  So is there something missing or am I misunderstanding your problem?
Derek.

3 (edited by borisavljevic 2020-06-27 03:52:04)

Re: [SOLVED] Need help - stucked. Project with explanation attached.

Yea, you are right, my mistake:
Example 3 from attached project:

(1) sum of preventive time = 235
(2) sum of corrective time = 221
(3) maxumum machine work = 210+185+184+160 = 739 hours > 739*60 = 44340 minutes 
RESULT 1 = 2/3 = 221/44340 = 0.005 > converted to procents 0.005*100 = 0.5%
RESULT 2 = 2/(1+2) = 221/456 = 0.485 > converted to procents 0.485*100 = 48.5%
RESULT 3 = number of preventive maintence's for selected period
RESULT 4 = number od corrective maintence's for selected period 

Also, side question, when I export any TableGrid to Excel using button > export to Excel, all integer values from TableGrid in Exel table appears with 14 decimals. Is it possible to format export without decimals?

Thank you for your time,

Vladimir

Re: [SOLVED] Need help - stucked. Project with explanation attached.

Hi Vladimir,
Please have a look at the attached as one way of doing it.
I've tested it with your 3 examples and they work (although example 2 has small differences due to rounding which you may want to change).
With regard to exporting a tablegrid, I don't use Excel so I can't say;  I use LibreOffice Calc and integer, real and currency fields all export correctly.
Regards,
Derek.

Post's attachments

Attachment icon KPI Project 2.zip 351.06 kb, 302 downloads since 2020-06-27 

Re: [SOLVED] Need help - stucked. Project with explanation attached.

I'll do tests with more data, but at first look it seems to work perfectly fine. Such simple and great solution, there is a lot to learn from you, sir.
Also, is it possible to format DateTimePicker1 so, by default, you choose only month and year and day will always be first day of the choosen month and DateTimePicker2 > you also choose year and month and day to always be last day in the choosen month.  This is because calculations will always be done in months as periods (one or more months), there is no need to pick days?

Again, thank you for your time and for your help,
Vladimir

Re: [SOLVED] Need help - stucked. Project with explanation attached.

Hi Vladimir,
All you need to do is to change the format of the datetimepicker fields (have a look at the attached screenshot).
1.  Set the 'filter to' >= and it will always pick the first day of the month (and <= if you want it to select the last day of the month).
2.  Set the 'format' to be MM-yyyy (or MMM-yyyy etc).
3.  Set the 'kind' to 'monthyear'
When you run your program, in the 'monthyear' picker, you need to click on the 'month' part before using the up/down arrows to change the month and then you need to click in the 'year' part before using the up/down arrows to change the year.
Derek.

Post's attachments

Attachment icon vladimir month year picker.jpg 350.77 kb, 115 downloads since 2020-06-27 

7 (edited by borisavljevic 2020-06-27 15:36:03)

Re: [SOLVED] Need help - stucked. Project with explanation attached.

Perfect. Just one small problem. If you want to change multiple months at once clicking on UP or DOWN button multiple times, every time you need to select (click) on MONTH field again. Is it posiible to select month field automaticly after clicking on UP or DOWN? I tried with

procedure Form1_DateTimePicker1_OnKeyPress (Sender: TObject; var Key: Char);
begin
  Form1.DateTimePicker1.SetFocus;
end;

but it doesn't work. Not a big deal...

Thaks a lot,

Vladimir

8 (edited by derek 2020-06-27 16:15:46)

Re: [SOLVED] Need help - stucked. Project with explanation attached.

Hi,
Highlight the month and then enter the 2 digit month number (for example, to go directly to February, enter '02', to go directly to  November, enter '11' etc.).
It's a (very!) small point, but if you do this, it might be better to change the format of the datetimepicker fields to MM-yyyy so that there is consistency between what you enter and what is displayed otherwise you are filtering using a 2 digit numeric format and it displays as a 3 character short month name.
Derek.

Re: [SOLVED] Need help - stucked. Project with explanation attached.

I see now, it works nice.
Man, words can's say how much I appreciate your help and your time.

Thank you very much,
Vladimir