Count rows after summarizing

sadath

Active Member
Joined
Oct 10, 2004
Messages
268
Office Version
  1. 365
Platform
  1. Windows
Hi

My 2 tables look like below

table1 >> Store_Name Sales_Man Date Sales
table2 >> Store_Name Sales_Man Date Target


How can i get number of stores which sales more than target.
Sales_Man name in row filter and in value area should show how many stores (count) achieved the target, for the given period of date (date is selected from slicer).


eg. if date 1st Apr to 10th Apr is selected from slicer
then formula should calculate the total sales & total target for each store then calculate how many sales are more than target

Can anyone help
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi sadyboy,

First make a lookup table of all unique Store_Name values (with no duplicates). Name the table "StoreLookup".

Add this lookup table to your data model, then make these two relationships:
StoreLookup[Store_Name] to Table1[Store_Name]
StoreLookup[Store_Name] to Table2[Store_Name]

Create an new empty PivotTable from the Data Model

From the Excel Worksheet with the PivotTable, add these three measures:

Table Name: Table2
Measure Name: TotalTargetSales
Formula: =SUM(Table2[Target])

Table Name: Table1
Measure Name: TotalSales
Formula: =SUM(Table1[Sales])

Table Name: Table1
Measure Name: CountStoresGreaterThanTarget
Formula: =SUMX(VALUES(StoreLookup[Store_Name]),IF([TotalSales]-[TotalTargetSales]>0,1,0))

Now add these fields to your PivotTable:
Filters: (Your date field)

Values:
fx TotalTargetSales
fx TotalSales
fx CountStoresGreaterThanTarget

The end result should look something like this...

Book1
BCDE
1
2Date(Multiple Items)
3
4Row LabelsTotalTargetSalesTotalSalesCountStoresGreaterThanTarget
5Store017007231
6Store021,4001,0330
7Store037003000
8Store041,4001,4881
9Store057009551
10Grand Total4,9004,4993
Pivot
 
Upvote 0

Forum statistics

Threads
1,225,730
Messages
6,186,698
Members
453,369
Latest member
positivemind

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top