How to assign weights to counts in Google Data Studio? - google-sheets

I have a data set with events and attendees and along with that also the focus area of the events. All events have a focus area 1 and some have multiple focus areas (2&3).
My goal is to have a tree map or pie chart that shows the number of attendees by focus area. If there are multiple areas then I do not want to count the attendees twice but basically assign a weight of 0.5 (when having 2 areas) or 0.33 (when having 3 areas).
Is there a way to accomplish this in Data Studio (can also include some pre-work in Google Sheets)?

The data has to be rearanged in follwing tables:
Event, Area, Topic, Areavisited, Attendance
Event1, 1, Security, 2, 56
This means you need to unpivot your table. It is possbible to do this in data studio with blend. However, no further field can be added to a blend dataset. Therefore, every calculation should be done in Sheets
Here is an example, how to do this with google sheets using pivot.
First generate a Vistfocus =CountA(B2:D2), counting the focus done at each event. Then do a pivot on that table and add as rows, the event/name and each focus-field. Add a summery row for focus2 and focus3. As Values add the attendance and Visitfocus. In H3 insert following formual:
=If(A3<>"",B3,if(A2<>"",C2,if(A1<>"",D1)))
Thus, the values from focus1, focus2 and focus3 are alternating between the rows. Extend this formula over the whole row. And name it Focus
Import this Sheet in Data Studio and filter all null values in ´Focus`.
https://docs.google.com/spreadsheets/d/1J_HxbqW9FGn1FCI8iOOvvz7u4lrs-YsY1V4R7Yg8DBQ/edit?usp=sharing

Related

Tableau: Subset multiple time dependent histograms into multiple rows and columns to fit the screen

I am trying to replicate the plot below (done with ggplot in R) using Tableau:
However, I can't see how I can subset the plot so it fits the screen using Tableau. Using Tableau, this is what I get:
I've attempted adding the following but it stops plotting the histograms and ends up messier:
Row Divider (Discrete):
INT((INDEX()-1)/(ROUND(SQRT(SIZE()))))
Columns Divider (Discrete):
(INDEX()-1)%(ROUND(SQRT(SIZE())))
How can I achieve the plot in R using Tableau?
P.S.: The datasets are different in case you were wondering why Monday doesn't look the same.
You're on the right path using Row-Column divider, but you need to go some step further using the small multiple technique.
For instance, you need to move WEEKDAY in the detail mark and then, use column and row divider in column and row shelf.
Doing so, you'll also need to right-click on CNT/Ride Id Hash) and compute it with WEEKDAY.
Here's a cool guide by a Tableau Zen master showing how to work with this tecnique: https://www.vizwiz.com/2016/03/tableau-tip-tuesday-how-to-create-small.html

Google Sheets: How to make a stacked/aggregate chart

I have made a bar chart which aggregates my data, but is there any way I can split each bar based on the data it is aggregating - similar to how a stacked bar chart would look?
Here is a bad artists impression (thick blue lines mine). The idea is that it's important to know from looking at the graph if I sold 5 at £1, or 1 at £5.
Ideally this would work even if the price for each item is variable, but that is not essential (eg: if there is a 'hack' with hardcoding Apple = 3, I can live with that.)
I'm also fine inputting helper columns etc, within reason, but I would want to be able to easily continue to add things to the list on the left without having to add new helper columns each time (calculated ones are fine, of course.)
Thanks in advance.
UPDATE: With thanks to Kin Siang below, I ended up implementing a slightly modified version of their solution, which I am posting here for completeness.
I added a very large (but finite) number of helper columns to the right, with a formula in each cell which would look for the nth occurrence of the item in the main list (wrapped in an iferror to make the unused cells blank).
=iferror(index(FILTER($A:$B,$A:$A=$D2),E$1,2))
Theoretically it could run out of space one day, but I have made it suitably large that this should not be an issue. It has the advantage over the other solution that I do not need to sort or otherwise manipulate the input range and can continue trickling in data to the main list and have the chart automatically update.
Yes, it is possible to display the chart in your case, however need some data transpose in order to do so, let me show you the example with dataset
Assuming this is your original data:
First sort the data by alphabet, and enter this formula in new column
=if(G39="",1,if(G40=G39,I39+1,if(G40<>G39,1)))
Next add new column for categorical purpose, by using concatenate function
="Price"&I40
In the transform data for chart purpose, enter this formula to split all price into different row, different column for different product
=sumifs($H$40:$H$47,$G$40:$G$47,$A41,$J$40:$J$47,B$40)
After that i select stack bar chart and ensure the price in under series, in case in 23 will have some problem to set price at series correctly, you can use 33 data create stack bar chart and update the data range again, it will work also
Here is the cute chart you expected, accept if help :)
*When certain fruit has less price record, it is advised to fill in 0, as the data table need in same column (see the orange price 3), although I didnot test if blank

Google sheet: How to automatically add all columns to graph series?

I have a pivot table with many columns.
I create a multi-bar chart graph with series of the columns.
How can I automatically set the range to be the active range of the whole table?
After choosing the whole range, only 6 series are added automatically.
How can I select all available series to appear on the multi-bar graph?

How do I dynamically expand the range of rows/columns to which a chart takes the data from?

I have the below pivot table, and i created the chart only with the data inside the table, excluding the bottom line with the totals and the right column with the grand total. If new rows automatically appear, how can I make sure they autimatically get added to the chart without having to add the bottom line as well?
best option would be to use FILTER or QUERY formula on separate sheet or hidden columns to trim down your pivoted output and feed it to chart because charts do not support advanced formulae as an input

Editing labels of series in Google Spreadsheets

I have data listed in columns as below and by highlighting it all including the names and the units and then clicking Insert -> Diagram..., I can easily make the following graph:
The labels are correct LabelA, Labelb, and LabelC in this case.
But if the label names are not in the same column as the data, then I cannot make this graph. In the data structure below where names and data are in different columns, I again highlight all data cells as well as their units and names (by holding down the ctrl button and clicking all the cells with the cursor):
It is clear that the software does not know that it should assign the names as labels. Is there a method to make the graph show the correct labeling as in the first scenario but with the second scenario's data structure?
you could combine the data in another place with formula:
={{A1,C1,E1};{B4:B6,D4:D6,F4:F6}}
and then plot the diagram as usual.

Resources