KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Sort by calculated value in the group #714

Open Eugene opened this topic on on Feb 27, 2019 - 7 comments

Eugene commented on Feb 27, 2019

Hi,

is it possible to sort the output in the table in the following way:

I have a table with a group like this

"grouping" => array( 
    "recipeName" => array(
        "calculate" => array(
             "{costRate}" => function ($store) {
               .... 
                return costRate;
            })))
...

is it possible to sort the data in the table by {costRate}?

KoolReport commented on Feb 27, 2019

Sorry Eugene, it is not possible now.

KoolReport commented on Feb 27, 2019

Sorry Eugene, it is not possible now.

Eugene commented on Feb 28, 2019

Ok, No problem :-) I think I could try to organize it using SQL or/and additional column But could you tell me what is the default sorting in the table - same as in datastore?

KoolReport commented on Feb 28, 2019

Table by default will show exactly what order in datastore, however if there is group settings in table, it will tell datastore to order to group, also if "sorting" settings is provided to table, it transfer to datastore to sort as well.

Eugene commented on Feb 28, 2019

Hm... ok if for example, I have a column costRate where the value is the same for each recipe So something like this

recname    item    price    costrate
recname1    item1.1    10    30
recname1    item1.2    20    30
recname2    item2.1    30    25
recname2    item2.2    40    25
recname2    item2.3    50    25
recname3    item3.1    60    28
recname3    item3.2    70    28

how to get a table like this where data grouped by recname and recname sorted by costrate?

recname1
         item1.1    10
         item1.2    20
recname3
         item3.1    60
         item3.2    70
...
KoolReport commented on Feb 28, 2019

you may use the "sorting" settings of Table. Your data will be sorted by costRate however within the group it belongs to. What I told that it is not possible now is to sort by aggregated costRate for the group ( for example the sum of costRate in a group), we use that aggregated costRate to sort the group to group. The group with higher costRate will be on top for example.

Eugene commented on Feb 28, 2019

great. I will try. Thanks

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

None