reports_kit icon indicating copy to clipboard operation
reports_kit copied to clipboard

Order by aggregation

Open jwiel86 opened this issue 7 years ago • 1 comments

I have this .yml file:

measure:
  key: adherence_top_five_bottom_five
  name: Percent Adherence to ACOG Guidelines
  aggregation: percent_correct_steps
dimensions:
- key: session_date_time
  granularity: month
  label: Month
- key: site
filters:
- branch
- session_date_time
- site
chart:
  type: line
  datasets:
    fill: false
    lineTension: 0
  options:
    legend:
        position: right

I need to display the top 5 results in the chart. In order to do so, I need to order DESC by the aggregation "percent_correct_steps" and then limit the results. Is there currently a way to do this?

Thanks!

jwiel86 avatar Jan 10 '18 20:01 jwiel86

Hi I think the best way to go about this is to create your own custom data method and use which will offer you more flexibility in the future or set up a limit_filter in .yml file

filters:
  - take_five

And then limit the return to 5 top results in the model, for example

User.limit(5)

and then in your view, add a limit filter, which is set to true

<%= label_tag :take_five do %>
    <%= f.check_box :take_five, :checked => true, :style => 'visibility: hidden' %> <span></span>
<% end %>

nsoseka avatar Jul 04 '19 11:07 nsoseka