Google Data Studio apparently bugging year sorting in combined data sources - google-data-studio

I have a combined data source that seems to work fine when I sort a bar chart using any metric.
However, as you can notice, the years are not in correct order.
When I select sorting ("Classificar") as year ("Ano") it bugs.
I noticed it is classifying "Ano" in the sorting area as a metric, but as a matter of facts thats a dimension. I didn't manage to find a way to change that.
About the data:
Ano is years in XXXX format
Receita LĂ­quida is Net Revenues in number format
Am I doing something wrong or that's a data studio bug and there is nothing we can do?
Unfortunately, not using combined data sources is not an option in this case (but when I cancel the combined data sources, it works fine and sorts by the year as it should be - still as a metric but it works).

Well, no one answered and I finally found a way to solve it.
Google Data Studio is indeed bugging the year sorting. However it only happens if year is a date object or a number. I fixed it when I turned it into text.

Related

Comparation Periods in Google Data Studio

I'm creating a in google data studio that has a table behind with data by day.
I need it to be comparable with the month before, but there's a catch that I'm currently stuck!
The period should be something like:
DAY(date)/MONTH(date)-1/YEAR(date)
This allows the comparation between periods with different number of days, example:
Date of analysis: 28/06/2021 - 27/07/2021
Date of comparation: 28/05/2021 - 27/06/2021
When trying to create something like this in DataStudio (with date range controls) none of the options does this, and for what I've explored, there isn't an option to do a formula like the one above.
The closest I get is "Previous Period" but that makes the Date of Comparation 29/05/2021 - 27/06/2021, missing the 28/05/2021.
I'm really stuck and running out of ideas, I've even considered changing the SQL query behind to convert the days somehow.
I've done this by mocking the dates for the comparator.
The other way is to create two series, and don't use the comparator.
Series #1 will have label 28/06/2021 and data from 28/06/2021 (current period).
Series #2 will have label 28/06/2021 (the same) and data from 28/05/2021 (previous period).
They plot nicely:

Datastudio: Blended Data: Date aggregation not working

I have a blended data source, that connects two filtered Google Analytics metrics. In there I have a calculated chart field, that gives me the ratio between these two filtered metrics. Now I'm trying to change the date aggregation to year-month, but there seems to be a problem.
This is with date auto, which is perfect:
However this is what happens with Year Month aggregation:
There should be only a line per month left, but somehow the aggregation is not working.
Do you have any idea on how to fix this? I've setup my blended data source at least 10 times trying to use the date on one source or as a key, but none worked.
Cheers
Andreas
I didn't find a fix either. Worked around it by making a custom field with the function MONTH(date) and using that. Works like a charm
Your solution did the job perfectly. Thank you, Joppe. I am quoting your workaround as an answer to bring more visibility to it.
Credit: Joppe De Cuyper (comment in the question)
Best solution here :
https://support.google.com/looker-studio/thread/96504295?hl=en
I have found others with a similar issue
https://support.google.com/datastudio/thread/65220021?hl=en
The workaround I guess is to maybe have dedicated column that represents date month in your source data. So 01-01-2021 for all Jan 2021, etc. As long as they are the same it should work I think.
WORKAROUND
You can use the following Formula and add a calculated field to your source table:
DATE(YEAR(your_date_column),MONTH(your_date_column),1)
Last edited Feb 3, 2021

Previous years registered: Excel COUNTIF and RETURN for X years

UPDATED screenshot after attempting #Dude_Scott's suggestion:
Desired output of data is in the blue table.
Our data includes users who have registered between 1989-2016.
All have registered at least once.
Some register every year and some skip years.
Our question is for each year, find how many years previous users registered.
We want results to be 0yr, 1yr, 2yr, 3yr, etc., for each year.
Arrays are working correctly.
I've organized the data structure in Excel this way:
1) UserID All Years
For year 1989, result is 0, since it was the first year of data collection.
For year 1990, this formula returns the expected count:
=COUNT(IF($B$2:$B$11613=1989,1/COUNTIFS($A$2:$A$11613,$A$2:$A$11613,$B$2:$B$11613,1989)))
Beginning with year 1991 is where I am tripped up: I can't find for multiple years.
This formula is not working:
=COUNT(IF(AND(OR($B$2:$B$11613=1989,1990,1/COUNTIFS($A$2:$A$11613,$A$2:$A$11613,$B$2:$B$11613,1989,1990)))))
Where do I argue "COUNTIF 0 yr, 1 yr, 2 yr", etc. Thanks in advance. --f66
Since your using COUNTIF, I'm assuming you can use SUMPRODUCT also. In the below screen shot I am using this formula
=SUMPRODUCT(($A$2:$A$11=$D3)*($B$2:$B$11<=F$2))&" yr"
Without a sample of the workbook its a little difficult to determine what the output of your data should look like, but give it a go.
Side note, I would suggest updating the User ID and Years into a table format and giving it a named range, so you don't iterate though tens of thousands of lines with the array formula.
I may be reading this all wrong, but this seems to be a straightforward use case for a pivot table!
Select your data range
Set USERID as your row headings
Set YEARS as your column headings
Set count of USERID as your values
I do not use excel anymore, but below is a link to output for doing this with test data on google sheets.

How can I aggregate date data with EntityFramework but without skipping entries with no data?

How can I aggregate data by week with EntityFramework but without skipping weeks for which there is no data? So, basically if there is no data for given week - I want to get 0 or NULL as a result for that week.
Agreeing with Luke's comment above, if you know the weeks included in the search, can you just push your results onto a pre-filled week->result Map of some type initialized to zero?
A quick google shows this smarter than me guy likes this answer too:
http://thenullreference.com/blog/analytical-queries-using-entity-framework-over-date-ranges-using-linq/

Hide weekends on WPF toolkit chart

I am making a small app that plots financial price data and since the finance markets are closed on the weekends, I have no data for those days. By default the chart, found in the new WPF Toolkit, shows a large gap between Friday and following Monday and this behaviour is not acceptable. I am trying to figure out a way to "hide" the weekend gaps but can't seem to find any good solutions. So far, I figured that I would have to overload the standard DateTime struct (how?) which will be able to recognize and skip weekends and holidays. I am looking for suggestions and/or pointers before I start down that slippery slope.
Some more details:
I am given a wide range of data - currently daily closing prices on NYSE. I am using the DayTimeAxis to plot the independent variable of LineSeries which is of type DateTime. It currently simply plots all the prices, one day at a time - and that's where the devil is, it shows wider gaps due to lack of data for Saturdays and Sundays and some major holidays.
I will eventually have to show more detailed (hourly, minute) chart once data becomes available, but the problem will remain if the user will want to view hourly data for some Friday and the following Monday.
After much playing around with various options, I ended up using the CategoryAxis instead of DateTimeAxis. It treats each day as a category without inferring the relationship between the days.
The data can still be kept as DateTime objects for any necessary calculations and you just have to worry about the ToString (that's what CategoryAxis to label each category). Or just throw them all in as strings - technically calculations are done on the data points, not the array of dates so not much of a loss here...
If you will plot candlestick or ohlc you can't go with toolkit (you can but it will be VERY unpleasant) if you are open to use component use visifire's the one you may go. if you can't figure it out with that send a sample code please.
Completely off the top of my head, so I'm not sure how feasible this would be, but could you possibly set up a value converter on the Width property of the data point that would return "Auto" on a weekday and 0 for a weekend?

Resources