How can I exclude previous months of the selected month in Looker Studio? - google-data-studio

I am trying to create a month on month bar charts. When the user selects a month bar in another chart or when she tries to filter to one particular month, it should show bar of selected month as well as bars of subsequent months.
I thought that it would be good to generate a list of months from selected month to the end of year and have it as a dimension (x axis).
For instance, the selected month is November. So I should have a list of month from November to December.
To get the end of year:
month(datetime_add(BillingDate,interval 12-month(BillingDate) month)) -- value is December
However, I am stuck on how to to generate the list of month.

Create a date column in your dataset, ideally at a day level or if the data is already aggregated, set to the first of the month. Then create a date dimension_group in Looker with month as a timeframe and datatype of date.
dimension_group: BillingDateDate {
type: time
timeframes: [
date,
week,
month,
year
]
convert_tz: no
datatype: date
sql: ${TABLE}.BillingDate ;;
}
then in your Looker dashboard, create a filter and use the BillingMonth field (generated from your dimension group) to filter the month on or after the required month

Related

How can I make last month name dynamic in title using Google Data Studio?

I would like to create a custom field in score card so the titles of the tables are dynamic.
I would like to make 3 of them:
Current month > February
-1 month > January
-2 month > December
Below example of dashboard:
https://datastudio.google.com/reporting/0a45e6ba-deba-41d1-b158-87b29c6990a2
I already have tried something like Todate((),-1,MMMM) but that did not work.
Below a image for extra information.
It can be achieved using Scorecards with the following Calculated Fields:
0) Scorecard Settings
The configuration that will be used for all three Scorecards:
Data Tab
Aggregation: MAX (either MAX or MIN would result in the same value, thus selecting either Aggregation would be fine, in this case)
Type: Date & Time > Month
Style Tab
Hide Metric Name: Select (☑)
1) Current Month
The DATETIME_TRUNC function is used to get the CURRENT_DATE at a more granular level, in this case, by MONTH:
DATETIME_TRUNC(CURRENT_DATE(), MONTH)
2) Last Month
This uses 1) Current Month as the base and wraps it with the DATETIME_SUB function, which subtracts 1 MONTH from the CURRENT_DATE MONTH value:
DATETIME_SUB(DATETIME_TRUNC(CURRENT_DATE(), MONTH), INTERVAL 1 MONTH)
3) -2 Months
Replaces 1 with 2 in the INTERVAL 2 MONTH section of the DATETIME_SUB function from 2) Last Month:
DATETIME_SUB(DATETIME_TRUNC(CURRENT_DATE(), MONTH), INTERVAL 2 MONTH)
Editable Google Data Studio Report (Embedded Google Sheets Data Source) and a GIF to elaborate:

What is the correct way to add and remove columns inside another column at runtime in Ext JS?

I want to build a grid that displays the number of hours an individual has worked where each column represents one day. Each day column should be inside a month column. In the gui I can select a start date and the grid should display one month -1 day worth of days, e.g.:
| January | February |
|Day6|.....|Day31|Day1|.......|Day5|
I have tried to delete the days inside a month column using destroy() on each day column, but when when the last day column is destroyed, the parent column (month) is also destroyed automagically (can I prevent this?).
I have also tried to delete the month columns and add new month columns containing day columns but this results in a very strange behavior, se example:
If i begin with this:
| January | February |
|Day6|.....|Day31|Day1|.......|Day5|
and delete January and February with destroy(), and straight after add new months containing the correct number of days I end up with duplicate of days in the grid like this:
| January | February |
|Day6|.....|Day31|Day6|.....|Day31|Day1|.......|Day5|Day1|.......|Day5|
As if the month column was never destroyed or as if the column was destroyed but the view is not updated correctly.
So to the question. What is the correct/best way to delete and add columns at runtime with the following requirements:
(At runtime when selecting a new start date:)
Delete month column OR all day columns inside the month column.
Create a new month column and populate with correct number of days OR add new day columns to the month column.
Thanks in advance!

Aggregate dimension values by month and year

I've been tracking a bunch of dates (with format string) under the dimension 'Product' in Google Analytics.
In Data Studio, I then have a simple Line Chart with all these dates (x) and their respective List Views. Like this:
Is there a way to aggregate these days by month and year?
Like this:
2020-08
2020-09
2020-10
and so on...
Thanks in advance for your help.
Summary
The below creates a Date field and then uses the Date field in a Time Series chart with Date Granularity.
1) Product_Date
Creating the TODATE Data Source-level Calculated Field below to extract a Google Data Studio recognised Date field (where Product represents the current Date field):
TODATE(Product, "%Y-%m-%d", "%Y%m%d")
GIF to visualise the process:
2) Date Granularity
Chart Type: Time Series
Date Range Dimension: Product_Date
Dimension: Product_Date; set the Granularity as required (Year, Year Month, etc)
Drill-down (Optional): Select and set multiple Date Granularity as well as a default Drill-down.
Google Data Studio Report and a GIF to elaborate to the above:

Google Data Studio Ignores Saturday and Sunday when Indicating Yesterday in Custom Date Filter Default Range

I am creating a report in Google Data Studio which pulls numerous days-worth of data; however, I want the report's date filter to default the initial presentation data to ONLY display the previous BUSINESS DAY's data.
I can set the default date range to "Yesterday" (or today minus 1) using the Advanced option. That get's me part of the way; however, the overnight, batch data I received each is based on activity conducted the prior weekday (Monday-Friday).
So, a date range of "Yesterday" (or today minus 1) works find when my report is executed on a Tuesday through Saturday, but if it is executed on a Sunday or a Monday, no data will show.
Is there a way Data Studio can handle this scenario? Essentially, I need "Yesterday" to ignore weekend days of Saturday and Sunday.
So I got this answer from Google Support
Click the pencil icon to edit your data source
Duplicate your date field and change the type to Day of Week
Add a control (type Drop-down list) to your dashboard.
Set Date range dimension to Date
Set Dimension to Day of Week and default selection 1,2,3,4,5.
You can do something like this:
CASE
WHEN (date_field = DATETIME_SUB(current_date(), INTERVAL 4 day) AND weekday(current_date()) = 1) THEN DATE(DATETIME_SUB(current_date(), INTERVAL 2 day))
WHEN (date_field = DATETIME_SUB(current_date(), INTERVAL 3 day) AND weekday(current_date()) = 1) THEN DATE(DATETIME_SUB(current_date(), INTERVAL 1 day))
WHEN (date_field = DATETIME_SUB(current_date(), INTERVAL 1 day) AND weekday(current_date()) = 2) THEN date_field
WHEN (date_field = DATETIME_SUB(current_date(), INTERVAL 3 day) AND weekday(current_date()) = 2) THEN DATE(DATETIME_SUB(current_date(), INTERVAL 2 day))
ELSE null
END
and then use that as your date range dimension. It basically makes Fridays and Thursdays look like yesterday and the day before on Monday and Friday the day before for Tuesday so you can use custom data ranges with the yesterday and previous period filters

Drupal views UI, filter exposed, the date in collection field's content only by month and year (no day)

Is it possible to add an exposed filter with only month and years parameters ?
When I add this filter, the user must choose the day, the month and the year. I don't want the "day option"
The format of my date field in the content is : Month Year.
This field is contained in a collection fields.
My content struture is like :
content
-some field
-some field
-collection fields
- date field (format : month year)
- some field
...
When you add a date field in the Filters section, you can select the "Filter granularity". Changing it to a month will cause the filter to only expect month and a year from the user, but not the day.

Resources