Looker date pivot is not working as expected - pivot

I am having an issue with pivots by date. When I try to add a pivot by date it ends up stacking month over month.
All the percentages are correct for each month showing and they line up with the correct names but for some reason its stacking.
I did try to remove the date from the table and then add it as a pivot but for some reason I get this odd stacking behavior.
I suspect it might be due to the way the custom measures work since I have not seen this happen with a normal measure before.
See example:

Turns out the solution was to change the data in the view from a dimension to a measure and to change the type from a number to a sum.
After doing this to both fields I am using for creating the percentage it corrected the way the pivot was displayed.
Results:

Related

Excel - A row in my Pivot table calculates sum wrongly only for some entries (same data type/format)

I created a tracker of learning hours in order to conduct an experiment.
For the purpose of the ticket, there is a time series that does not sum correctly data in Pivot table.
Some other tickets on Stack Overflow mention how to correctly sum. Here's what I tried:
considered blank spaces > the Pivot does not consider them anymore, yet the issue persist.
data type & format > the whole column is set for data type short date
labeling > I use to copy-paste the category for each learning and I double checked if there was no typo in them.
Here's how the file works. There are 3 sheet in my Excel file. The core of it is "Data" where I do track the time spent for each learning / exercise. The columns marked in red are the ones used for the next Pivot Table.
These information are consolidated in another sheet, called SuperLearner Review. I use this one to display overall learning hours by type and category. Numeric outputs here are looked up from Data (or calculated accordingly).
After several checks, I cannot retrieve the issue. All I know is that for February data are not tracked correctly.
Originally I attributed either to wrong data labeling or format, but I can manually see what is the real sum of learning done in February:
In the data-series those hours seem not to display. This is what the Pivot table returns instead:
Whereas, for the consolidated information (coming from the same source) does not seem there are problems in calculation:
When I tried to cancel and build up again the same Pivot Table, the same error occur. So I am not getting out of this wrong calculation. Therefore it must not be a problem of calculation, rather than Excel does not retrieve some data entries at one point.
What would you recommend? Thanks for the help.

Pivot Chart - 3 date columns, how to show counts of the dates by month?

My goal is to have a count of three different dates by month in a bar chart. Currently we are using a count if formula then building the chart above that, would like a cleaner solution. I have three columns, Open, Action, and closed dates. Adding all three to the axis doesn't produce the right results. I'm stuck. Is there something in the pivot that I can change? I'm pulling the data in via Power Query, is there something there I can change? Many thanks :-)
Ideal state
Recent Action and Closed dates are not show up, that seems to be the real issue. Why and how to fix it?
Sample of data
Created a date table in Power Query.
Also in Power query, duped my data then deleted all but the columns I didn't need.
Unpivoted the three date columns.
Joined the new date to the date table.
Graphs fine.

Excel Pivot Table difference in columns of "shown as" values

Is there a way to let a pivot table calculate the difference between 2 columns automatically when the values are shown as a % of the parent column total?
Now I need to to manually but the table is dynamic and number of competitors may vary. Function seems so easy but can't find it after googling etc...
See example picture below of what I want to achieve.
(Column F automated by the pivot table is the goal)
If trying to solve this with PivotTables, you've got a couple of options:
Use a 'Traditional' PivotTable that's based on a range. This will give you percentage differences, but you can't get percentage point differences like you're asking for without using external formulas.
Use a 'OLAP' PivotTable that's based on data you've added to the Excel Data Model. This will give you both percentage differences and percentage point differences, without having to resort to using external formulas.
In both cases, I recommend that you unpivot your data first, so that it is in what's known as a Flat File. Currently you're using a cross-tabulated data source (i.e. your source has columns called Year 1, Year 2), and the type of percentage comparisons across years you want to do doesn't work if your data is a crosstab. Basically, PivotTables aren't meant to consume cross-tabulated data.
Instead, you really want your data laid out so that you have a column called Amount and a column called Year, and then you can use the Show Values As options available from the right-click menu to show as percentage differences across years. To transform your data into a flat file, see my answers at convert cross table to list to make pivot table
That said, you can still use the GETPIVOTDATA function on your existing (unpivoted) data layout in a way that is somewhat more robust to changes in your PivotTable structure than just subtracting one reference from the other:
But again, I recommend transforming your data into a Flat File. Then you can additionally do the following:
Using a 'Traditional' PivotTable:
You can kinda solve your problem entirely within a self contained 'Traditional' PivotTable if you drag the Amount column to the Values area, put the Year column in the Columns area, put your Competitors in the Rows area, and choose one of the percentage Show Values As options you'll see when you right-click a cell in the Values area.
I say kinda, because without using external formulas (or without calculating the percentages back in your source data), you can only get it to show percent increases (see far right column), not percentage point increase like you want (see far left column). That said, I think percent increase is less confusing. But I guess it depends on what you want to show. If you want to show say change in market share from one year to the next, then percentage points make sense.
Of course, you could always use the GETPIVOTDATA function to do the additional math for you like we did earlier, like I've done on that left hand side.
Using an OLAP PivotTable based on the DataModel
Calculating percentage point increases likely requires using PivotTables built using the Data Model. See my answer at https://stackoverflow.com/a/49973465/2507160 that explains a little about the Data Model (although it doesn't answer this specific question).
Here's the result:
Here's the measures I used to do this:
Total Year 1:
=CALCULATE(SUM(Table2[Value]),ALLSELECTED(Table2[Competitor]),Table2[Year] = "Year 1")
Total Year 2:
=CALCULATE(SUM(Table2[Value]),ALLSELECTED(Table2[Competitor]),Table2[Year] = "Year 2")
% Year 1:
=CALCULATE(SUM(Table2[Value]),Table2[Year] = "Year 1")/[Total Year 1]
% Year 2:
=CALCULATE(SUM(Table2[Value]),Table2[Year] = "Year 2")/[Total Year 2]
p.p. Diff:
= [% Year 2] -[% Year 1]
You can add Calculated Fields to Pivot Tables, of varying levels of complexity. Finding the difference between two fields is about as simple as it gets.
The example below is borrowed from contextures.com, where there are many more examples more further information.
To add a calculated field:
Select a cell in the pivot table, and on the Excel Ribbon, under the PivotTable Tools tab, click the Options tab (Analyze tab in
Excel 2013).
In the Calculations group, click Fields, Items, & Sets, and then click Calculated Field.
Type a name for the calculated field, for example, RepBonus.
In the Formula box, type =Total * 3%
Click Add to save the calculated field, and click Close.
The RepBonus field appears in the Values area of the pivot table, and in the field list in the PivotTable Field List.
(Source)
EDIT:
#jeffreyweir - I'm not gonna lie, I don't know off the top of my head how to make this work (and don't have time to experiment) but by the looks of these options, isn't a calculated field with a "straight subtraction" of existing fields (ie., 3$-2%=1%) very possible with Difference from? (as opposed to % Difference from which is also an option but for a different result).
In fact, automatic year-over-year difference reporting should be readily possible with the <previous> and <next> comparison operators...?
                                 (Click to Embiggen)
     
Also, did you see the link where I got the example? Kind of a hoakey site but it has some more complex pivot table instructions.

Excel Pivot Tables - Calculated Field of a Calculated Field

I'm using Excel 2010.
I have a data set of widgets made by person by period. I created a calculated field that shows each person's widgets made as a percentage of the total for each period.
I would like to now show the change in that "percent of total" from period to period. That is to say, I want to see how each person's percentage of the total widgets made has change from the previous period. It's a calculation on a calculation and perhaps it's just wishful thinking that Excel supports this, but it would be great if it did.
Can anyone confirm if this is possible and if so, how would I approach it? I've been looking into creating a custom Calculated Field, but I don't see how to do percent to total or difference from in those (perhaps because it would be redundant?)

Sorting error for Time row value in Pivot Table

I've encountered an issue with a pivot table that I occasionally use, though I don't update. Specifically there are three Row Fields applied Year, Day (d-mon format), and then Transaction Date/Time (which displays only the hour component of the value). The pivot table is supposed to sort by Year, then Day, then Hour. The first two sorts work fine, but the third has started to sort the Hour values as text rather than numbers, so it's ordered 1 AM, 1 PM, 10 AM, 10 PM, etc. I've checked and there are no non-time values in the source field, the column of the pivot table itself is still set to a Time format type, and there are no filters applied to the field.
At this point I'm not sure what else to look for. Any assistance would be much appreciated.
UPDATE: The file is in Sharepoint so I tried taking the prior version (there are only two), dropping in the latest data from the current version, and refreshing the pivot table. The error dutifully appeared. So it does appear to be a data issue, but I can't imagine what's causing the issue. As stated above, I already checked that the values were Dates, specifically I used =IF(NOT(ISERROR(DATEVALUE(TEXT(C2, "m/d/yyyy h:mm"))), "", 1) and checked that all rows returned as blanks.
Something that may be causing issues is how the Year and Day fields come about. Specifically, there are no such fields in the Source Data, they are calculated Row Fields based on the one Transaction Date/Time column. I'm not even sure how this was done (to my knowledge calculated fields can only be columns) so I can't really look into if it may be causing the errors.
I also had this problem and found no good way around it in Excel. What I ended up doing (that worked for me) is to extract the 24hour "hour value" from a date field using =VALUE(TEXT(A2,"h")) (where A2 contains the time/date code I'm looking for). I then used the date code itself (Column A in this example) as the first Row Label (first grouped item) then added the "hour value" as a secondary Row Label/Group. This allows leveraging the Pivot Table sort/group function naturally and then adds the detail in the order I want.
I did not solve the problem for 12 hour display with AM/PM as this was good enough for my needs.

Resources