A pivot table to show standings from game data - google-sheets

I have a game data where each team plays 2 games per week. I want to make a pivot table to get the current standings. I would expect the below data to show Team 1 is 4-0 and Team 2 is 0-4. I've tried a lot of combinations of pivot tables but just cant quite get it. Do I need an extra column for game (1 or 2 each week)?
I've tried the following pivot table configuration:
But that just leads to is saying Team 1 has 20 W's and Team 2 has 20 L's (its not just getting one unique one per game, hence why I might need game column?)
Below is sample data:

Related

Trying to get the size (in %) of subcategories in a pivot

I am keeping track of my (stock) portfolio in Google Sheets, as follows:
category subcategory company amount
-------------------------------------------
health care diagnostics AA 100
health care diagnostics AB 50
materials mining BA 75
financials banks CA 30
financials insurers CB 35
financials banks CC 10
financials banks CD 40
financials hedge fund CE 5
health care equipment DA 50
But now I want to extract some statistics from this, and I'm using a Pivot. Specifically, I want to see:
the relative size of each category in the portfolio
the relative size of each subcategory in the portfolio
the relative size of each company in their subcategory
The first two I get done:
For instance, I can see that:
category financials has a relative size of 30% in the portfolio
subcategory diagnostics has a relative size of 37.97% in the portfolio
What is missing however, is the third column, see mockup below:
I can now see in the last column what the relative size of each company is in its subcategory:
Company CD is 50% of the subcategory banks
Company AB is 300.33% of the subcategory diagnostics
That last column however, is not calculated but added manually to show what output I am trying to get but am unable to.
Does anyone know how to have this last column as part of the Pivot?
Here is a link to the Google Sheet used: Pivot
Currently, there is no % by subtotal option in Google Sheets to show percentages against subtotals for the whole Pivot Table:
As a workaround, you can display the subtotal percentages by filtering the Pivot Table to display only one subcategory, for example:
Add Filter here and select subcategory:
Then select the desired field, for example, banks, and click OK.:
This should display the subtotal percentages like this:
Note: You can delete category field in Rows to make the Pivot Table cleaner.
You can also submit a feature idea request to Google Workspace, please see instructions on this site: Submit ideas for Google Workspace and Cloud Identity
So I found out there are two possible solution using calculated column and another using arrayformula.
Option 1: Use a duplicate pivot table. One issue of getPivotData function is that it will run in the table calculations stage so it will return empty result. So the solution was to have two clones of the pivot table. One will be used to retrieve the data and the other to retrieve the subtotal.
The formula to use would be
=amount/getpivotdata("amount",'Copy of Pivot'!$F$10, "category", category, "subcategory", subcategory)
Where amount, category, subcategory without the double quotes are values (references) filled by Google Sheets. While the double quoted ones are column names.
You also need to set summarize by to custom for it to work.
The only issue I found here is that I couldn't find a way to identify subtotal or total rows, they do have company value equal to the first record in the group. If anyone know how to know if I am rendering a subtotal, please let me know.
The second option is to use one pivot table only but reference original data.
=amount/SUM(QUERY($A$1:$D,"Select D Where A='"&category&"' AND B='"&subcategory&"'",false))
It still shares the same total rows though.
The last option will be the least robust. It would be using arrayformula but I don't have that ready at the moment. It is main issue is that changing the column orders or adding new columns will require to keep the position of the refenced columns and move the arrayformula columns. Not to mention, handling the empty cells in a category since data is grouped.

How to Sum with limits (google sheets)

Background:
I have an odd issue with Google sheets, I have a bunch of tournament results lets say
Team 1 comes 1st at 10 events, 2nd at 3 events and, 3rd at 8 events.
I need to take only their top 15 events which in this case would be:
1st - 10 times
2nd - 3 times
3rd - 2 times
Then this needs to be applied to a large number of teams (around 100) and a lot of events
My Current Solution:
Currently I have a solution for tracking all total results for a given team
=sumif("first_place","team name","all total results")" I then repeat this formula for each column of results e.g. "=sumif("second_place","team name","all total results")","=sumif("third_place","team name","all total results")
Problem (need advice):
however I am not sure how to limit this to only their top X results across all events.
update
I've settle on this formula as a temporary solution
=If(COUNTIF(Team_position,H2)< 6,Sumif(Team_position,Team_Name,team_points),"Team has played more than 6 events")
It simply gives me an error once a team plays more than the required number of events

Count total games played in a league standings template

I'm working in Google sheets
I've created a league standings template here:
https://docs.google.com/spreadsheets/d/1aTJsKkORRka1f4Z3Ibb87XGq-6Sv3qFaCYSsW8D3kHM/edit?usp=sharing
The last thing I'm really hung up on is calculating the amount of games that each team has played. Basically I need the G column to use the formula for each cell to see if the corresponding team has completed their games from the 'League Scores' table.
I currently have this formula:
=countif(filter($C4:$C, $B4:$B=$J$4), "<>") + countif(filter($D4:$D, $E4:$E=$J$4), "<>")
Each team could play on either side of the league score sheet throughout the season. So my logic is that the first 'countif' function would search through the first Team name column and Scores column to see if the team name was mentioned. If it was, it would then check to see if there was any score listed at all. If true, then it would add one to the Games played counter. The second half of the formula is to check the right side of the leagues team and score columns repeating the same process.
You can see however, that the 'GP' (games played) column lists an inaccurate amount of games played per team and even saying that teams which haven't yet played a game are at 2 games played.
What am I missing?
The extra count is coming from the case when the filter returns no rows and you get #N/A. The Countif still counts it as 1.
Suggest using Countifs instead, something like
=countifs(B:B,J4,C:C,"<>") + countifs(E:E,J4,D:D,"<>")

Delphi FastReports - How to change Rows?

Delphi Tokyo, FastReports V5. I have a report that I cannot seem to get correct. The report is showing information for 1 sales rep. It contains two Master Data bands and 1 detail data band. Within Delphi, the pseudo code looks like this:
For each sales rep in table
Get Rep ID
Filter ActiveOrders DataSource based on rep ID
Load report definition
Execute report
Export Report to PDF
Next Sales Rep
This works fine for a simple report, such as one that only has a single MasterData band. My report is a little more complex. Specifically, it has two MasterData bands, which are only slightly related. The first band works fine with the pseudo code above. The second band is ONLY a graph. The graph has 4 datasources, because each datasource is tied to a series (aka each datasource adds a different line to the graph). I cannot figure out how to handle the coordination of the data.
My report looks like this.
As an example... the rep is Bob. Bob has 6 active orders, which shows up fine in the top MasterData band, as 6 rows of data. Of those 6 active orders, there are 3 separate companies. I want a graph of each company (in MasterData2). Below each graph, I want detailed data about the orders for that company. I want this to show up as
Graph of Company 1
Details of Company 1
Graph of Company 2
Details of Company 2
Graph of Company 3
Details of Company 3
I can write the queries to get the correct data. I just can't figure out HOW to coordinate the data changing. Since the MasterData2 is a graph, I can't return the data for all 3 companies, or FastReports will try to graph all the rows. How do I tell MasterData2 WHICH data to look at, and how do I tell it that there are more companies to graph (aka another Master/Detail) set to process?

"Relationship may be needed" although relationship is set

I have two simple table in Excel 2010 - Products and Sales:
I then linked them into PowerPivot - and here created the relationship from Sales.ProductId to Products.Id - like this:
Now I'm trying to build a Pivot that for each productId in the Sales table also shows me the Category and the PurchasePrice from the ProductTable. However, here I'm stuck - because the relationship is somehow faulty. When configuring the Pivot, I get a message Relationship may be needed even if the relationship already exists. The resulting - wrong - pivot table looks like this:
though I'm actually trying to achieve this:
I know that I could create calculated columns in the Sales table of PowerPivot and pull all required data using the RELATED DAX function - but as the real world project requires a lot of joins and fields I'm hoping that there's a better solution than this workaround...
I uploaded the example file here.
Peter,
Your question was a bit more tricky than I first though and I spent quite some time digging around, but I think I found the solution after reading this article about making distinct count in related tables.
I have updated your source file (so that Sales table contains more than 1 sales per product) and uploaded it to my public Dropbox folder.
You can see that I created 4 new calculated measures to illustrate my solution and to make it a bit easier to understand (Excel 2010 terminology, in 2013 it's Calculated Field):
Sales Price Total
=SUM(Sales[SalesPrice])
Products Sold
=COUNT(Sales[ProductId])
Purchase Price per Item
=CALCULATE(SUM(Products[PurchasePrice]),Sales)
Purchase Price Total
=[Purchase Price per Item] * [Product Sold]
The key difference here is the formula for calculating purchase price per item. The reason why you should SUM the product purchase price within CALCULATE function is explained in great detail in the linked article (even though in a bit different context):
In this way, any filter active on Sales (the related table) propagates
to the lookup table.
There might be some other parts I missed, but I have tried this in couple other examples and it simply works as it should:

Resources