How can i set views filter to show specific content based on actual month? - drupal-7

The content that i want to show is random pictures in views block. Few of them needs to by shown on January, others on February, others on March, and so on.
Showing of specific content will reapeats every year (example: only in january in every year)
I have created vocabulary for that content type with "January", "February", "March" as values. Every photo has one of these values.
And now is the part where i am stuck:
I want to add views filter which points to that vocabulary with additional actual date rule, like:
IF date('m') = january THEN set filter to Vocabulary Months = January else
IF date('m) = february THEN set filter to Vocabulary Months = February ... and so on.
Can someone tell me by wich modules i will achieve this?
I did this already by using Date Repeat module but for user it means, that he needs to put some extra values in 3-4 additional fields - and that is "not simple".
Any advice?

I'd switch from a taxonomy field to a date field (i.e. set month as a date field value on the images), then use the current relative date as a filter.

Related

Data Studio Time Series Chart Last 6 Month based on Date Filter EndDate

Can I have a time series chart to display the last 6 months QTY sold? as the report filter is monthly based.
ex. Users can choose 2021/10/01 - 2021/10/31 to view the report and there is a chart to display the last 6 months QTY sold. In this case, the time series chart will display 2021/05/01 to 2021/10/31.
If users can choose 2021/06/01 - 2021/6/30 to view the report and there is a chart to display the last 6 months QTY sold. In this case, the time series chart will display 2021/01/01 to 2021/06/30.
Through my advanced knowledge of the platform, I am not aware of the possibility of obtaining the mentioned result.
It is not possible to use the date filter control element and the respective date range as an input variable to define the period dimension used in the temporal graph.
You will probably have to look for an alternative solution that doesn't match the proposed objective. Using a fixed period of the last 6 months, without the possibility of dynamic variation through the date control element. Or, use two date filter control elements, one for the time graph only. Solutions far from ideal.
The issue was solved, I created another data source for 6 months of sales.

Data Studio - Grouping by Week

I have a simple Data Studio table consisting of two columns. The first column is the week (ISO Year Week) and the second column is the total registrations we've received for that week.
However, my Week column repeats 7 times (7 Rows) for each week as it's counting by day within that week. See below:
Is there any way to get this to group by the listed week? Below are my settings:
Dimension = Conversion Date set as "ISO Year Week" for the type.
Metric = Equals the count of Conversion Date (Same Conversion Date field used for dimension)
Any help would be much appreciated.
There might be an issue with the date format of the source. Without knowing the source (e.g. Google Analytics or Sheets) it’s hard to tell.
Blended Data
I recently had this issue with blended data. The response of a similar question helped me to find a way.
Basically you have to add a new custom field to the data source with the formula WEEK(date_field_link). Data studio will recognise this as a date in compatibility mode, but for me it still works. Then you can use this new date field as a join key to blend the data while grouping it in weeks.
Normal Data
If this problem appears in a regular non-blended dataset you might want to check if Data Studio correctly catches the date as a date. This help article from Google might be worth checking out: https://support.google.com/datastudio/answer/6401549?hl=en#zippy=%2Cin-this-article
I made a similar case work using blended data.
Your column "Conversion Date" repeats the same week 7 times because it's just a display value. Every row has a date value (year, month and a day) but you're just showing the corresponding week. So, data-studio treats them as different data and doesn't group them.
To be able to group them by Week you need to create a new field with a value containing only the week and the year. So, you can use the formula
YEARWEEK(your_date)
The resulting Date will be groupable.
NB1: If your date isn't of the type Date, you can parse it from text to date using
the method:
PARSE_DATE("%Y-%m-%d", your_date_text)
NB2: If the created field has the type number and doesn't show the possibility to change type to Date, you can do this trick: (it's weird but it works):
First type as a formula for the created field and apply:
MONTH(your_date)
This will unlock the compatibility Date types. You can choose from them the ISO Year Week type.
and then change the formula from MONTH(your_date) to YEARWEEK(your_date) [your formula] as I explained above. The chosen date type won't go away even if it wasn't available the first time.

Google Data studio -Default filter on last month when data is at month level

I have a report with one data source in Google Data Studio. The data is at month level inside the BigQuery table YYYYMM (for example 202001). I have a filter that is set on the year-month dimension which works ok but I would like to add a default value which changes to last month(max(year_month)) available in the table.
Is this possible? I only found the option to hard-code the default selection but this can't be updated dynamically
as in this screen shot
Jaishree's suggestion
You can create an another field/column as same year-month and always keep the latest year-month value as "latest month" or any name you want. You can use logic like
when existing_column = max(year_month) then "latest month" else existing_column
Something like this
existing_column new_column
022020 latest month
012020 012020
122019 122019
112019 122019
You can pass this "latest month" value in the default selection option this option which is just below the dimension. But each time you upload new data you have to update this field like change the table suppose for next month you table should be like
existing_column new_column
032020 latest month
022020 022020
012020 012020
122019 122019
112019 122019
You can make auto update by scheduling queries as well in big query from where you are loading data to Google data studio.
It can be achieved by setting the Date Range (at the chart, report level, Date Range Control, etc) to Last Month.
First, a YYYYMMDD Date field needs to be created at the Data Source. This can be done using the CONCAT function to add a Day (the 15th is used in the formula) and then using the TODATE function (although in this case the TODATE function is not required, however, adding it as best practice):
TODATE(CONCAT(Date, "15"), "%Y%m%d", "%Y%m%d" )
Adding a link to post on the Google Forums (Nimantha; 10 Feb 2020) which also has a GIF to demonstrate the process above as well as adding the Date field at the Report Level.
You can do it by creating a new field where rows that belong to the current year-month are labeled as 'Current Month' while the others could use your preferred formatting (I'm using "%Y%m - %B %Y" as it allows me to sort report dates in a drop down list).
To do so, you need your date column and CURRENT_DATE() in the same format with the help of FORMAT_DATETIME(). Then, you can use CASE WHEN logic as follows:
CASE
WHEN FORMAT_DATETIME("%Y%m", MyDateColumn) != FORMAT_DATETIME("%Y%m", CURRENT_DATE())
THEN FORMAT_DATETIME("%Y%m - %B %Y", MyDateColumn)
ELSE 'Current Month'
END
Finally, you could use a drop down list control with the new field and use 'Current Month' as the default selection. The main advantage is that the code above will be evaluated every time data is refreshed so no extra automations needed.
Hope it works for you.

ValueFilter for DateTime Attributes

I'm working with the Blog app and I see how to filter the Blog posts by year using the Visual Query Designer. I use the querystring value that has the year and in the ValueFilter and my properties are as follows:
Attribute: PublicationMoment
Value: [QueryString:year]-01-01 and [QueryString:year]-12-31
Operation: between
How would I get the posts from a specific month and year, if those values are passed via query string parameters. Because the months of the year have a varying number of days, I'm not sure how you would accomplish this in the Value field of the ValueFilter. Currently I'm passing the 2 digit month as the parameter.
I tried something like: [QueryString:year]-[Querystring:month]
Operation: contains
but the above operation doesn't really work because the datatype is a DateTime object.
I could do it in the razor view but I'm afraid that the paging datasource would have too many pages in it since it would be based on the larger subset of posts for the given year that was passed in the querystring parameter.
Is there any way to do this with the filter?
Basically dates are not perfectly handled yet, but there are a few ways to do it using the visual query:
Use the correct date in the query like between [QueryString:Start] and [QueryString:End] and calculate the correct dates there where you generate the links
Since your main problem with the "between" filter is actually that it would include the last day too, you could also use a two filters a >= first date and another < second date, so the first-date would be the year/month and day 1; the second one is year-month and day 1 as well
Last but not least: if you do it with razor and LINQ you shouldn't run into any performance issues - it's technically the same thing the pipeline does and it's been tested to perform well with tens of thousands of records.

Can a drupal view return groups that have no associated rows

I have an event view that is grouping an html list by date. The display I want to create is a "week" display with columns for sunday 1st, monday 2nd, tuesday 3rd ... saturday 6th. It's working great when I have an event on every day, but when there are days with no events I get no group (or column) for that day. Is it posible to modify my display to return groups (ie days) that have no results. Am I going to have to do something crazy like create a template for the display that has the 7 columns determines the start date from the exposed filter and the corresponding dates for the every day of the week? blah...
Any help would be greatly appreciated.
In your contextual filter of your View, can you edit the NO RESULTS BEHAVIOUR in advanced settings ?

Resources