Combine columns of Pivot Table in Excel - excel

I have a pivot table that displays the Count of Items, the Avg. Sell Price, and Avg. Supplier Price. I need to find the difference between the Sell Price and Supplier Price and their percentage difference. I have tried using Calculated Fields, but they only work on an individual cell level. The data is organized as Purchaser, Item, Item Id, Sell Price, Supplier Price.
My table is as follows:
Row Labels (Item) | Count of Item Id | Avg of Sell Price | Avg of Supplier Price
A | 3 | $2 | $1.9
B | 4 | $3 | $3.25
I know the difference would be Avg. of Sell Price - Avg of Supplier Price, but you cannot subtract columns in a Pivot Table.
How does one perform this calculation?

Related

Count of number of unique customers by month

I have a spreadsheet that contains data for customers that have purchased items from my store. What I would like to do is go back the last couple years, using a pivot table, and display: number of customers that ordered something each month (a count of unique customer names).
The sheet is organized as such:
Date | Invoice | Account Name | Item | Quantity | Amount
6/1/2020 | 50100 | John's Tire Shop | 1/2 Inch Socket | 2 | 12.00
Is there a way inside pivot table options to count unique account names and display the total grouped by month?
You can create a helper column to identify unique values per month to add as a filter to your pivot using your existing setup
=IF(COUNTIFS($A$2:A2,A2,$B$2:B2,B2)=1,"y","n")
I would propose you to add a helper column to your data, containing the =Month(A:A) function. But be careful: I see that your first date equals "6/1/2020", is that the first of June or is this Epiphany? :-)

Max Value of a column in the same year and month

I have to columns I want to analyse, visits and dates. I now want the max visits of a month. The data ranges over multiple years.
+--------+--------+---+
|Date |Visits |Max|
|31.12.19|77 |77 |
|01.01.20|47 | |
|02.01.20|121 | |
|03.01.20|133 |133|
...
|01.02.20|21 | |
|02.02.20|135 |135|
+--------+--------+---+
You can create easily a Pivot Table:
More about Pivot
Tables
To create this Pivot Table I did:
Date field into Rows Section and grouped by Years and Months
Visits field into Values section and selected option MAX
Group Pivot Tables
Items

How to show previous period sales of items that didn't have sales in current month in Power Pivot?

When displaying prior month sales, I noticed that items with no sales in current month are missing in the Pivot Table output of the data model. However, the grand total sales includes sales of those missing items.
I created a small data model to replicate the issue: 2 tables (1 sales table and 1 calendar table) and it has 1 single DAX formula:
Previous Month Sales:=CALCULATE(sum([Sales]),PREVIOUSMONTH(Sales[Date]))
In the output table, I would have expected 1 more item row for Potatoes, with 0 sales in current month and 31 in previous month.
Is there a way to force-show Potatoes item in the pivot table above when selecting date 24/03/2019? Can this be achieved with DAX formulas?
You need to use the Date field from your Calendar (Date) table, for Time Intelligence to work as you intend:
So change your Previous Month Sales measure to:
Sales Previous Month:=CALCULATE (
SUM ( Sales[Sales] ),
PREVIOUSMONTH ( Calendar[Date] )
)
I'd also recommend creating an Explicit Measure for Sales:
Sales Total:=SUM ( Sales[Sales] )
Now you can recreate your pivot output, using Date field(s) from Calendar in your slicer / filter, and you should get the output you require:

How do I negate a value in an Excel calculated field for a pivot table?

I've got a pivot table that has a sum of numbers aggregated per month per category. My data table looks like this:
Date | Description | Amount | Transaction Type | Category | Account Name
---------------------------------------------------------------------------------
12/16/2017 | Dinner | 150.00 | debit | Restaurants | CC
12/16/2017 | Return | 80.00 | credit | Restaurants | Cash
For the calculated field's formula, I've tried =IF('Transaction Type'="credit", -1*Amount, Amount) but it's just giving me the same sum of Amount. For this sum, I'd expect it to be 70.00 (150 - 80). Not sure what to do here.
You are after adding a calculated item rather than a calculated field as you are relying on the value of the field "Transaction Type" to determine the calculation result. See reference here
I assumed (oops) you meant credit - debit but, if not, simply swop the items around in the formula.
With your initial pivottable set up
With either Debit or Credit in the column headers of the pivot selected goto
Fields, Items, & Sets in the Analyze tab and selected Calculated Item
then add the following:
Name: Net
Formula: =' credit '-' debit '
Example layout final:
As noted in the link:
You will:
NOT be able to move the field to the Report Filters area
NOT be able to add multiple copies of a field to the Values area.
Extra items might be created in the pivot tables, such as cities
appearing in all regions, with zero values.

Pragmatically Get Count of Pivot Table Data

Suppose I have some sample data like so:
and I create a Pivot Table and order by Product > Sales Rep > Sales
If I want the # of sales John had for Product1 I would do =GETPIVOTDATA("Sales",$A$3,"Product","Product1","Sales Rep","John")
But how would I get a count of the entries there are. i.e. for Product1, John had 4 and Kevin had 2
Is it possible to get this count using GETPIVOTDATA()?
To get this you need to add another Sales field to the values section and change the "Summarize By" to Count. Then the formula will =GETPIVOTDATA("Count of Sales",$A$3,"Product","Product1") will get you the count of Product Overall.

Resources