In Power Pivot, one of the major and more powerful feature areĀ Measures.
Measures (also known as Calculated Fields in Excel 2013) areĀ formulas/calculations that are added to a Pivot Table.
We will work on a simple example to show you how easy it is to use the COUNTROWS function in yourĀ Measure.
STEP 1: Select the Sales Table. Go to Insert >Ā Table. Ā ClickĀ OK.
STEP 2: Go to Table Tools >Ā Design > Table NameĀ and give your new Table a descriptive name. Ā In our example, we will name itĀ Sales
STEP 3:
In Excel 2013 & 2016
Select your SalesĀ Table. Go to Power Pivot > Add to Data Model.
This will import your new Table into theĀ Power Pivot Window.
In Excel 2010
Go to PowerPivot >Ā Create Linked Table.
STEP 4:Ā This will open theĀ Power Pivot Window.
TheĀ Sales Table will nowĀ be automatically loaded to the Power Pivot Data Model.
Now Close theĀ Power Pivot Window.Ā
STEP 5:Ā Go toĀ Insert> Pivot Table.
In Excel 2016
SelectĀ Use this workbook’s Data Model. Ā This will use the Data Model you just uploaded in the last step.
SelectĀ Existing Worksheet and chooseĀ your location for your Pivot Table and press OK.
In Excel 2013
Go to Use External Data Source > Choose a Connection
Now selectĀ Tables > This Workbooks Data Model > Open:
In Excel 2010
Go to Use an External Data Source > Choose Connection:
Now selectĀ PowerPivotĀ Data > Open:
STEP 6:Ā Adding a Measure:
In Excel 2016
On theĀ SalesĀ Table, right click and selectĀ Add Measure.
An alternative way inĀ Excel 2016Ā is go to Power Pivot > MeasuresĀ > New Measure.
In Excel 2013
Go toĀ PowerPivot > Calculated Fields > New Calculated Field
(In Excel 2013 “Measures” were renamed “Calculated Fields” and returned to “Measures” in Excel 2016…I know, how annoying!)
In Excel 2010
On theĀ Sales table, right click and selectĀ Add New Measure.
An alternative way inĀ Excel 2010Ā is to select a cell inside the Pivot Table that was created in the previous step and go to Power Pivot > New Measure:
STEP 7:Ā This is where we create our MeasureĀ using the COUNTROWSĀ function.
For Measure Name,Ā type in any name that you like e.g.Ā Number of Sales
For theĀ Formula, after the = sign start typing the word COUNTROWS.
Just like in native Excel, this will bring up the Formula helper and choose the COUNTROWSĀ function by either double clicking on the blue highlighted COUNTROWSĀ option or by pressing the Tab keyboard to confirm this suggestion:
After the COUNTROWSĀ formula is selected, type in the Table name that we created in Step 2, which we called Sales.
This will bring up the Formula helper and within here you need to select the SalesĀ Table option andĀ close the parenthesis:
Set theĀ CategoryĀ as General, and this will automatically handle the formatting for you. Ā Press OK to confirm this.
This Measure will now returnĀ the Total Number of RowsĀ based on the Pivot Table we will be setting up in the next step.
STEP 8:Ā Place your new MeasureĀ Number of SalesĀ in theĀ ValuesĀ area.
Then placeĀ MonthĀ in theĀ RowsĀ area
STEP 9:Ā Now we are able to use our new COUNTROWĀ Measure in theĀ Pivot Table.
Bryan
Bryan Hong is an IT Software Developer for more than 10 years and has the following certifications: Microsoft Certified Professional Developer (MCPD): Web Developer, Microsoft Certified Technology Specialist (MCTS): Windows Applications, Microsoft Certified Systems Engineer (MCSE) and Microsoft Certified Systems Administrator (MCSA).
He is also an Amazon #1 bestselling author of 4 Microsoft Excel books and a teacher of Microsoft Excel & Office at the MyExecelOnline Academy Online Course.