• 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.

Errors on calculation because of repeated sub-group

ThierryM

Member
Hi,
I have a problem with the results of calculations "count" or "sum" for the elements (no matter the type of element).
It seems like the calculations include the repeated sub-groups.
I try to explain with one field :
- field "Adh?sion valid?e" : number of values =1 (OUI) -> 1
Result with calculation count number of values =1: 18 values ???!!!

So I tried to understand why I obtain 18 and not 1 as expected. I see that the field "Adh?sion valid?e" belongs to a sub-group with an other sub-group repeated with 18 records. If I erase one record of the 18, the calculation count decrease of one.
So all my calculations are multiplicated by 17.
Sélection_076.png

This behavior doesn't affect the principal group (on the screen capture : Total ?coles =1 as expected) but the calculations for sub-groups.
I use an updated Github version of FABRIK.
Thanks for your help, regards,

Thierry
 
Well, if I'm understanding your setup correctly, that is what I would expect. If you have 17 repeats of a group, and you are counting an element in the repeat group ... there are 17 occurrences of it on the main "row".

I'm assuming you are doing "merge and reduce" on the joins. If you switch that back to "each row seperately" and display the list, I think it will make more sense to you.

-- hugh
 
Hi Hugh,

Thanks for your lightning. You are right (you have perfectly understood ;) ).

But I don't understand why the first column (belonging to the principal group : the other sub-groups are joined to it) is not affected by this behavior : it's counted 1 time and not 17 times ; I think it should be the correct behavior for all other the columns.
I'm a newbie but maybe, it would be interesting to have an option to choose this behavior in order to avoid this confusion : integrate or not the repeated datas for calculations (it's easy to suggest when you aren't the programmer).

For my problem, I found that the solution was to break the join with the repeated sub-group but I think this solution is less practical because an other form has to be created and so the informations are separated. But it's a detail in regard to the possibilies offered by Fabrik.

Thanks, regards,

Thierry
 
But I don't understand why the first column (belonging to the principal group : the other sub-groups are joined to it) is not affected by this behavior : it's counted 1 time and not 17 times ; I think it should be the correct behavior for all other the columns.

Remember that when you have a repeat group, the data in the repeat is not on the "main" table. It is on another table, with a one-to-many join. So you have you main row ('parent') with 17 rows in the 'child' table which are joined to it.

So let's say your parent table was 'invoice', and your child table was 'line_items'. So you have (say) two invoices, with the following ine item repeat groups ...


invoice #1, some customer, etc ...
  1. line item 1, can of soup, $2
  2. line item 2, bowl of ice cream, $1.50
  3. line item 3, bottle of wine, $5.00

invoice #2, some other customer, etc ...
  1. line item 1, bowl of rice, $1
  2. line item 2, bottle of vodka, $10

If you put a 'sum' on the "cost" in the repeat group ... what would expect the total sum to be at the bottom of the list?

If you put a count (total number) on the line items, what would you expect the total to be?

If you put a count on the customers in the 'parent' (invoice" group, what would you expect the total to be?

-- hugh
 
Thanks Hugh for your patience : I think it's clearest for me but not at all... ; I need to go further into database joins.

Here the schema of my tables and relations to understand my misunderstand :(.
The child tables 2 and 3 are not directly related.

Table1 Parent____ Table2 (repeated row) with 17 records
|______ Table3 (repeated row) with 1 count of one column

But the calculation is like this : Parent Table1____Table2____Table3

Maybe the order of the join is important to obtain Parent Table1____Table3____Table2 ?

Regards,

Thierry
 
As I said, "if I'm understanding your setup correctly, that is what I would expect. If you have 17 repeats of a group, and you are counting an element in the repeat group". But from what you are saying, I wasn't understanding your setup. So the element in question is not in a repeating group? In your explanation above, which table is the element in?

-- hugh
 
The elements counted are in the Table3.
See the screen of the jointures here (I added which are the tables 1, 2 and 3) :

Sélection_077.png

I hope it's more understandable.
Thanks for your help.
Regards,

Thierry
 
OK, thank you.

Yup, I suspect I know why the calculations happen like that, and it very probably is not a trivial issue.

-- hugh
 
Happy to have discovered an issue but sorry for you :oops:.
If you need, I can help you for testing : it's the least I could do.
Regards,

Thierry
 
I'm not going to have time to look at this one for a while, I have a pile of issues I'm working on in the paid support queue atm.

-- hugh
 
No problem at all : I'm a volunteer and I use Fabrik for an association so it's not imperative (and we don't paid support too).
But when it will be possible, you know I could test if needed.
Regards,

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

Thank you.

Members online

No members online now.
Back
Top