Hourly trend

Hourly trend

In this use case, you want to display a table and simple line visualization that shows an hourly trend of occurrences(events) for January 1, 2023.

Customer Journey Analytics

An example Hourly Trend panel for the use case:

Customer Journey Analytics Hourly Trend visualizations

BI tools
note prerequisites
PREREQUISITES
Ensure you have validated a successful connection, can list data views, and use a data view for the BI tool for which you want to try out this use case.
tabs
Power BI Desktop AlertRed Power BI does not understand how to handle date-time fields, so dimensions like daterangehour and daterangeminute are not supported.
Tableau Desktop
  1. Select the Sheet 1 tab at the bottom to switch from Data source. In the Sheet 1 view:

    1. Drag the Daterange entry from the Tables list in the Data pane and drop the entry onto the Filters shelf.

    2. In the Filters Field [Daterange] dialog, select Range of Dates and select Next >.

    3. In the Filter [Daterange] dialog, select Range of dates and specify a period of 01/01/2023 - 02/01/2023.

      Tableau Desktop Filter

    4. Drag and drop Daterangehour from the Tables list in the Data pane and drop the entry in the field next to Columns.

      • Select More > Hours from the Daterangeday drop-down menu, so that the value is updated to HOUR(Daterangeday).
    5. Drag and drop Occurrences from the Tables (Measure Names) list in the Data pane and drop the entry in the field next to Rows. The value is automatically converted to SUM(Occurrences).

    6. Modify Standard to Entire View from the Fit drop-down menu in the toolbar.

      Your Tableau Desktop should look like below.

      Tableau Desktop Graph

  2. Select Duplicate from the Sheet 1 tab context menu to create a second sheet.

  3. Select Rename from the Sheet 1 tab context menu to rename the sheet to Graph.

  4. Select Rename from the Sheet 1 (2) tab context menu to rename the sheet to Data.

  5. Ensure that the Data sheet is selected. In the Data view:

    1. Select Show me at the top right and select Text table (upper left top visualization) to modify the content of the Data view to a table.

    2. Drag HOUR(Daterangeday) from Columns to Rows.

    3. Modify Standard to Entire View from the Fit drop-down menu in the toolbar.

      Your Tableau Desktop should look like below.

      Tableau Desktop Data

  6. Select New Dashboard tab button (at the bottom) to create a new Dashboard 1 view. In the Dashboard 1 view:

    1. Drag and drop the Graph sheet from the Sheets shelf onto the Dashboard 1 view that reads Drop sheets here.

    2. Drag and drop the Data sheet from the Sheets shelf below the Graph sheet onto the Dashboard 1 view.

    3. Select the Data sheet in the view and modify Entire View to Fix Width.

      Your Dashboard 1 view should look like below.

      Tableau Desktop Dashboard 1

Looker
  1. In the Explore interface of Looker, ensure you do have a clean setup. If not, select Setting Remove fields and filters.

  2. Select + Filter underneath Filters.

  3. In the Add Filter dialog:

    1. Select ‣ Cc Data View
    2. From the list of fields, select ‣ Daterange Date then Daterange Date.
      Looker filter
  4. Specify the Cc Data View Daterange Date filter as is in range 2023/01/01 until (before) 2023/01/02.

  5. From the Cc Data View section in the left rail,

    1. Select ‣ Daterangehour Date, then Time from the list of DIMENSIONS.
    2. Select Count underneath MEASURES in the left rail (at the bottom).
  6. Select Run.

  7. Select ‣ Visualization to display the line visualization.

You should see a visualization and table similar as shown below.

Looker result daily trend

Jupyter Notebook
  1. Enter the following statements in a new cell.

    code language-python
    import seaborn as sns
    import matplotlib.pyplot as plt
    data = %sql SELECT daterangehour AS Hour, COUNT(*) AS Events \
                FROM cc_data_view \
                WHERE daterange BETWEEN '2023-01-01' AND '2023-01-02' \
                GROUP BY 1 \
                 ORDER BY Hour ASC
    df = data.DataFrame()
    df = df.groupby('Hour', as_index=False).sum()
    plt.figure(figsize=(15, 3))
    sns.lineplot(x='Hour', y='Events', data=df)
    plt.show()
    display(data)
    
  2. Execute the cell. You should see output similar to the screenshot below.

    Jupyter Notebook Results

RStudio
  1. Enter the following statements between ```{r} and ``` in a new chunk.

    code language-r
    ## Hourly Events
    df <- dv %>%
       filter(daterange >= "2023-01-01" & daterange < "2023-01-02") %>%
       group_by(daterangehour) %>%
       count() %>%
       arrange(daterangehour, .by_group = FALSE)
    ggplot(df, aes(x = daterangehour, y = n)) +
       geom_line(color = "#69b3a2") +
       ylab("Events") +
       xlab("Hour")
    print(df)
    
  2. Run the chunk. You should see output similar to the screenshot below.

    RStudio Results

recommendation-more-help
080e5213-7aa2-40d6-9dba-18945e892f79