Excel Power Pivot Measures – 5 Examples

A DAX code will be used to find average sales, commission, success rate of broker calls, and the greatest number of calls.

Overview of power pivot measures examples


Download Practice Workbook


Example 1 – Finding the Average Sales Using Power Pivot Measures

To create a pivot table:

  • Select the whole dataset.
  • Choose Insert >> Pivot Table >> From Table/ Range.

Adding Pivot Table

  • Select a New Worksheet to create the PivotTable.
  • Check  Add this data to the Data Model and click OK.

Adding pivot table and check the Add this to the data model

  • Check the fields shown below.

Choosing necessary data

  • Right-click Range and select Add Measure.

Adding Measure

  • Choose Average Gross Sales in Measure Name.
  • Enter the following formula in the Formula box.
  • Click OK.

=[Sum of Gross Sales]/[Sum of Total Quantity Sold]

Adding DAX formula for average

  • Check Average Gross Sales to see the output.

Finding average gross sales in power pivot


Example 2 – Finding the Commission Using Power Pivot Measure

  • In the previous Pivot Table:
  • Right-click Range in PivotTable Fields to create another Measure.

Adding another measure

  • Name the measure and enter the following DAX formula in the Formula box.

=IF (
        [Average Gross Sales]  > 20,     // Above $20
        0.05,                              // 5% Commission
        IF (
              [Average Gross Sales]  < 20, // Below $20
              0.03,                          // 3% Commission
              BLANK()                        // No Commission
              )
        )

  • Click OK.

Adding DAX formula for commission

Formula Breakdown

The code snippet uses nested conditional statements to determine commission rates based on the value of Average Gross Sales. If the sales are above 20, a 5% commission rate is assigned; Below 20, a 3% rate is applied. Otherwise, no commission is given, returning a blank output.

  • Check Commission.
  • This is the output. Use the Percentage.

Adding commission in power pivot


Example 3 – Finding the Total Order

The dataset was modified and named Table3.

Dataset of Stock broker calls

  • Insert a pivot table.

Select the necessary data for Pivot table

  • Add a new Measure for Table3.
  • Enter Total Order in Measure Name and use the DAX formula.

=SUMX(
SUMMARIZE(
'Table3',
'Table3'[Name],
"Total",
SUM('Table3'[Jan]) + SUM('Table3'[Feb]) + SUM('Table3'[Mar])+SUM('Table3'[Apr])+SUM('Table3'[May])+SUM('Table3'[Jun])
// Add more columns as needed for the sum
),
[Total]
)

Adding DAX code for total

Formula Breakdown

The DAX code uses the Power Pivot’s SUMMARIZE function to group data in Table3 by unique values in the Name column. Within each group, it calculates the sum of values for different months (Jan to Jun). The code creates a new calculated column called Total to store these sums. The outer SUMX function iterates through each group created by SUMMARIZE and calculates the sum of the Total column, resulting in the grand total of the calculated monthly sums for all names. This code computes the total value for each individual by summing their monthly data and provides an overall sum for all individuals combined.

This is the output.

Finally getting the Total Order column in power pivot


Example 4 – Finding the Success Rate

  • Insert a pivot table.
  • Add measures.
  • Add Success Rate in Measure Name and enter the DAX formula.

=[Sum of Stock Sold]/SUMX(
SUMMARIZE(
'Table3',
'Table3'[Name],
"Total",
SUM('Table3'[Jan]) + SUM('Table3'[Feb]) + SUM('Table3'[Mar])+SUM('Table3'[Apr])+SUM('Table3'[May])+SUM('Table3'[Jun])
// Add more columns as needed for the sum
),
[Total]
)

Adding DAX formula for finding success rate

 Formula Breakdown

The DAX formula calculates the ratio of Sum of Stock Sold to the total sum of monthly values (Jan to Jun) for each individual in the Table3. It groups data based on names, computing the sum of specified months for each group, and dividing the Sum of Stock Sold by the calculated total. The result offers insights into how the stock sold compares to an individual’s overall monthly activity, aiding in performance evaluation and analysis, and identifying the highest success rate.

This is the output.

Adding DAX formula for finding success rate in power pivot


Example 5 – Ranking According to the Success Rate

  • Insert a pivot table.
  • Add measures.
  • Add Rank in Measure Name and use the DAX formula.

=RANKX(ALL('Table3'), 'Table3'[Success Rate],, DESC)

DAX formula for ranking according to success rate

Formula Breakdown

The DAX formula calculates the rank of each individual in Table3 based on their Success Rate values. It considers all rows in Table3, orders them in descending order, and assigns a unique rank to each individual based on their relative performance.

This is the output.

Finally, we get the Rank column in power pivot


Things to Remember

  • Measures can be reused across multiple reports.
  • Keep measures concise and relevant.

Frequently Asked Question

1. How do I troubleshoot when a measure displays unexpected results?
Double-check your DAX formula, filters, slicers, validate your source data and measure logic for accuracy.

2. Are Power Pivot measures compatible with Power BI?
Measures may need adjustments when transitioning between the two platforms.

3. How do I optimize performance when working with Power Pivot measures?
Limit complex calculations, avoid circular references, and optimize your data model for a better performance.


 

<< Go Back to Power Pivot Formulas | Power Pivot Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Joyanta Mitra
Joyanta Mitra

Joyanta Mitra, a BSc graduate in Electrical and Electronic Engineering from Bangladesh University of Engineering and Technology, has dedicated over a year to the ExcelDemy project. Specializing in programming, he has authored and modified 60 articles, predominantly focusing on Power Query and VBA (Visual Basic for Applications). His expertise in VBA programming is evident through the substantial body of work he has contributed, showcasing a deep understanding of Excel automation, and enhancing the ExcelDemy project's resources with valuable... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo