Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Need help] How to create report with Hour (1 .. 24 hours) in Y axis and Date(Created At) in X axis #22

Open
kirantpatil opened this issue Dec 12, 2017 · 5 comments

Comments

@kirantpatil
Copy link

Hi,

I would like to create report where I need to know how many users created in which hour of the day.

Ex: If 2 users created at 1:10 pm and 1:20 pm, then I would like to show them on the map between 1 and 1:30 pm.

Usecase is to find the busiest hours of the day.

Thanks.

@tombenner
Copy link
Owner

Hm, I'm unclear about exactly what data you want to see here. Below is a guess at what you want, but if it's incorrect, could you provide a similar ASCII chart indicating what you want?

      5           |
      4           |
Count 3 |     |   |
      2 |     | | |
      1 |     | | |
        0 1 2 3 4 5 ... 23
            Hour of day

The above shows the number of users created by hour of the day. To generate it, you would use a custom dimension:
https://www.reportskit.co/examples/dimension_custom_dimension

The custom dimension would be defined using raw SQL in your model (the following is for Postgres; you would have to adjust the SQL for other database technologies):

class User < ApplicationRecord
  include ReportsKit::Model
  reports_kit do
    dimension :hour_of_day, group: 'EXTRACT(HOUR FROM users.created_at)'
  end
end

The YAML would be similar to what's shown in the documentation:

measure: user
dimensions:
- hour_of_day

@kirantpatil
Copy link
Author

@tombenner, thanks a lot, I will try it and get back to you.

@smitakiran25
Copy link

smitakiran25 commented Jan 5, 2018

Hi,
I would like to create where i need to display how many incidents created in each hour
i tried to created each day how many incidents created that is coming properly

screenshot from 2018-01-05 12-50-24

I would like to display in hours but its not coming properly the incidents has to display based on the hours (in 1pm how many incidents created 2.30 how many incidents created like that )
screenshot from 2018-01-05 13-06-33

i also sent that incident created details
screenshot from 2018-01-05 13-05-39

and also tell me how to display hours or days in order

@kirantpatil
Copy link
Author

@tombenner, your ascii representation is correct.

For us as you can see above created_at is in IST. The hours should have been 2, 5, 4, 12 but we are seeing 11, 9, 6, 12, 8.

Also graph is ordered based on count in ascending order rather on hour/day.

Where do we need to modify the code to get day/hour ordered and proper hours which are in IST ?

Thanks.

@iACM1994
Copy link

iACM1994 commented Sep 20, 2019

Hi,

I would like to get reports for each days requested_at.

currently, it show reports for 7 days.

image

how should I write in dimensions: ?

and also for the aggregation of amount for each days, how to achieve it?

/reports_kit/reports/report_sales.yml

measure: 
  key: sale
  aggregation: sum_of_grand_total
dimensions:
- key: requested_at
  limit: 5
- key: payment_status
  limit: 3

in model

include ReportsKit::Model
reports_kit do
        aggregation :sum_of_grand_total, [:sum, 'grand_total']
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants