1 (edited by Step-in 2023-12-18 06:36:04)

Topic: [SOLVED] Need help again. Problem with grouping

Hello again everyone. I cannot group the data by driver in any way. I need all data on the driver to be written in a line. Example:
Driver Dendy - trip#10003 in 11.12.2023 visit Canada,Japan,Norway and take 200; trip#10004 in 02.11.2023 visit United Kingdom,Japan,Norway,Poland and take 500.
Driver Marco - trip#10001 in 27.07.2022 visit United Kingdom, Japan, Poland, Hungary, Canada, United Kingdom, Japan and take 1000.
Driver Terry - trip#10000 in 27.07.2022 visit Sweden, Norway, Portugal, Poland, Japan and take 100; trip#10002 in 12.11.2023 visit Canada, Hungary, Japan and take 150; trip#10005 in 11.12.2023 visit Canada,Romania and take 50.

But with different layouts of fields I get either 3 values for each driver or all six for each separately.
Maybe someone knows how to group values in one line?

Post's attachments

Attachment icon autocomplete2-1.zip 343.61 kb, 48 downloads since 2023-12-11 

Re: [SOLVED] Need help again. Problem with grouping

Hi Step-In,
Probably a few ways to do it.
Attached is one suggestion using a calculated field;  I've used a second tablegrid to load the consolidated (one line per driver) data before running the report rather than hijack tablegrid1 (I didn't want to mess up your layouts etc).
Select a driver using the existing combobox (combobox2) or leave the combobox blank to see all drivers.
You'll probably want to alter the layout of the concatenated field and also the report so I didn't spend any time on them - it's more just to give an idea how you could approach it.
Regards,
Derek.

Post's attachments

Attachment icon autocomplete2-1-1.zip 348.45 kb, 88 downloads since 2023-12-11 

Re: [SOLVED] Need help again. Problem with grouping

Thanks for the answer. This project that I have attached is an example. In my project there are fields that are calculated when entered for printing in FastReport. Sorry for not giving a complete example... The problem is that I don't know how to group directly into a fast report. I think that a script is needed before printing, which would control the fields on the page. Maybe someone will point to the necessary manual or a similar script.

Post's attachments

Attachment icon autocomplete2-1-1.zip 345.04 kb, 46 downloads since 2023-12-12 

4 (edited by sparrow 2023-12-12 11:47:16)

Re: [SOLVED] Need help again. Problem with grouping

From your example and message it is not clear what should be calculated and what should be grouped and in which report.
Be specific about your question.
What do you want to get as an output and from what data.

Re: [SOLVED] Need help again. Problem with grouping

I have the following field in a report. Driver [<Report."Driver.Name">] - trip#[<Report."trips.record_count">] in [IIF(Copy(<Report."trips.tripdate">,7,4)>=Copy(<Date>,7,4),'this year ' + <Report."trips.tripdate">,'previous year '+<Report."trips.tripdate">)] visit [IIF(PosEx(',',<Report."trips.countriesvisited">,8)>0,'more than two countries - '+<Report."trips.countriesvisited">,'only two countries - '+<Report."trips.countriesvisited">)] and take [IIF(PosEx(',',<Report."trips.countriesvisited">,8)>0,(<Report."trips.amount">+200),<Report."trips.amount">)]


Below is an image with the text that is displayed when grouping and with the text that should be displayed.

Post's attachments

Attachment icon img.JPG 162.66 kb, 26 downloads since 2023-12-12 

6 (edited by sparrow 2023-12-12 18:40:23)

Re: [SOLVED] Need help again. Problem with grouping

Derek has provided you with a working solution.
If you edit the calculated field a little and change the Report a little you will get what you call GOOD.
Apply everything you described in the SQL query.
And in the report, remove the grouping.


And you will succeed

Post's attachments

Attachment icon driv-tr.jpg 107.99 kb, 28 downloads since 2023-12-12 

7 (edited by Step-in 2023-12-14 09:05:37)

Re: [SOLVED] Need help again. Problem with grouping

Thanks for the tip, but I didn't use it. To make it clear what I wanted, I am attaching the оption of solution. This is work with a report and not with a database.

But this solution does not work very correctly. Maybe someone will tell me how to properly organize a script in Fastreport?

Post's attachments

Attachment icon autocomplete2-1-1.zip 345.37 kb, 46 downloads since 2023-12-14 

Re: [SOLVED] Need help again. Problem with grouping

Implementing such a solution through the FastReport script will require significant effort and programming knowledge from you.

Once again, Derek's solution is optimal and requires a little modification to achieve the result you need.
Ok, I'll do it for you.
Here is Derek's modified solution in two versions.

Post's attachments

Attachment icon autocomplete2-1-1m.zip 17.15 kb, 47 downloads since 2023-12-14 

Re: [SOLVED] Need help again. Problem with grouping

Sorry, I looked at the wrong report. What exactly do you want to complete in the script?

Re: [SOLVED] Need help again. Problem with grouping

Added a window to display the output result. I can't understand why it doesn't display the first result... The script works, but only from the second time, that is, the first result is empty and all the others are displayed. Accordingly, the last driver is not displayed on the screen.

From this script, I want to get the same result as the SQL-query, but have a more flexible setting in the report.

Post's attachments

Attachment icon autocomplete2-1-1r.zip 344.51 kb, 46 downloads since 2023-12-14 

Re: [SOLVED] Need help again. Problem with grouping

If you look closely, you will see that the LAST result - Tery - is not displayed.
And if you look at your code, you will see that the previous driver is displayed when the driver is changed DriverName <> currentDriver. But the condition does not work for the last driver.

Re: [SOLVED] Need help again. Problem with grouping

Something like this.

Post's attachments

Attachment icon autocomplete2-1-1rr.zip 15.56 kb, 62 downloads since 2023-12-14 

Re: [SOLVED] Need help again. Problem with grouping

sparrow wrote:

Something like this.


This is fantastic. Thank you very much. Exactly what is needed. I just wanted to understand why I was not getting the grouped data of the last driver. Thank you very much for the detailed example. I will continue to study the features of programming and scripts. And thanks again.

Re: [SOLVED] Need help again. Problem with grouping

The FastReport script is no different.
You need to read the documentation and you will get an idea of how FastReport events work and how the output is generated on the screen.
Here is the link: https://www.fast-report.com/public_down … ual-en.pdf
FastReport's capabilities, which are described in the manual, are slightly larger. But you will get an idea of how it all works, including in the script.