• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Help with Custom Calc

bggann

Active Member
I'm trying to use a custom calculation on a field to show just the 1st or last record value in a grouped list display.
It doesn't matter if it is first or last, because all the values in that group are the same.

The reason is I want the "calculations" line to have the value of these fields along with the "Sum" values from other fields. I'm showing just the "calculations" line from each group in a custom template.

I realize I can use %s to get the 'value' of the field in a custom query, but it appears to return just the first record value for all groups. I tried to build a query to return the value based on the grouped by element, but could not get past sql errors.

To reiterate:
- I have a repeated group in a list.
- I display that list 'grouped by' one of the fields (elements) in the group.
- All the numeric values are totaled using the SUM calculation.
- There are 4 elements (text fields and one date) that are the same for all records in the group.
- I want to display them on the Calculations line in the list by adding a Custom Calc that returns the 1st (or really) any value in the group.
- If I just use %s in the custom calculation - I get the value from the first record of the list, not the first record from the group.

Ideas?
 
No ideas at all, and it's a long time since I've looked at the custom calc stuff - in fact you are the first person who has asked about it since I added it, I think.

I'll dig around in the code and remind myself how it works.

Which site / list / element of yours is this, so i can peek at it.

-- hugh
 
Okay - as usual with my sites, this is a bit complex

Access the training- site that is in my 'sites'
- Log into the front end
- Select "Reports/SEAT Reports/Seat Daily Cost Summary - Incident.
- On the list display
-- Select N number N804NZ/T862
-- Select a date range in early July (July 1-15 for instance) You need multiple days to show the issue
-- Go.

Scroll down - you'll see the date displayed below Total in the first column.
Notice that the date will be the first date in the list.
That was added by putting DATE_FORMAT(%s, '%m/%d/%Y') in the custom calc of that element.
--> It appears you simply put what I entered here in the value list of the query for the list and replace %s with the field name.

If you now group by "Flight Date" you will see that each group shows the same (1st) flight date of the list, not of the group.
What I want to show is the flight date of that GROUP of record.

In the back end the element is:
Flight Date in group Daily Log SEAT. (It is a child, of another group - you can edit it or unlink it)

-- If you use "Reports/SEAT Reports/Seat Daily Cost Summary - Incident - Collapsed". Follow the same filter/group steps. Nothing will display till you "group"

You will see what I'm trying to achieve. I'm trying to display just the "calcs" row of this of each group on this list, but I need the 'non-calculated' elements to show as well. I got it working by making a custom template and hardcoding element names in there. It is a nasty hack of a solution - but it works.

So if you are doing what I'm thinking, I'm not sure of any SQL formula I can put in the "value" list that will do what I want, but I haven't looked hard.

Bob
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top