# Tags: ALL

Here's a simple Sales data of a retail Store which sells Apple Products.  Since a customer can transact multiple times, there will be repetitions in the Cust ID column.  While Cust ID 123 and 782 purchased multiple products from the same Store in one transaction, Cust ID 53 purchased multiple products from different stores (Store ID 165 and 45) [and therefore the Order ID's are also different (Order ID 2 and 6)].

On this small sample, one may want to identify "Cross and up selling opportunities" i.e. one may want to know which are the Customers that can be approached for selling more products to.  So for e.g. one may want to know which Customers have bought only one product so far.  A case in point being the Apple Watch - Customer ID 2442 and 428 bought only this product.  The other Customers who bought the Apple Watch also bought atleast one more product.  Therefore, Cust ID 2442 and 428 could be approached for buying other products as well.

Solving this via conventional Excel formulas and Pivot Tables would prove to be a formidable challenge.  I have solved this problem using a Data visualisation software from Microsoft called PowerBI desktop (it can be downloaded free from the Microsoft website).  This problem can also be solved in MS Excel using Power Query and Power Pivot.

There are 3 sections in the image below - Table at the top (First Table), slicers at the right and another Table at the bottom (Second Table).

Interpretation of First Table

1. 1 appearing at the intersection of APPLE TV (row labels) and APPLE TV (column labels) represents that there is 1 customer who bought the APPLE TV
1. 1 appeaing at the intersection of APPLE TV (row labels) and MACBOOK AIR (column labels) represents that the 1 customer who bought the APPLE TV also bought the MACBOOK AIR
2. 4 appearing at the intersection of APPLE WATCH (row labels) and APPLE WATCH (column labels) represents that there are 4 customers who bought the APPLE WATCH
1. 1 appearing in other columns of the same row represents other products which those customers bought
2. When one right click's on APPLE WATCH and selects "Drill down", one will be able to see the Customers who bought the other products as well.
1. Customer 53 bought the APPLE WATCH, AIRPORT and IPHONE 8S.  Customer 123 bought APPLE WATCH, IPHONE X and IPOD
2. Customers 2442 and 428 did not buy any other product

Interpretation of Second Table

This table shows a list of Customers (and their transaction details) who bought only and only that one product selected by the user in the filter section (see the red oval selection in the image).  So these two customers could be approached for selling more products to.

This table contains a list of all the inspections created and completed within different time periods.

The objective is to create two Tables from this single table - one showing the Accounts created within the chosen time period and another showing the those that were closed within the same time period.  Here are screenshots of the expected results.

You may download my PowerBI desktop solution workbook from here.  The same solution can be obtained in Excel as well (using Power Query and PowerPivot).

Visualise a 5 column dataset as show below.  This is a very small sample of the actual dataset.  It shows the date on which supplies were received for each item from Vendors and whether those supplies had errors in them.  Finally those identified errors have been bucketed into relevant categories.  The Item ID# is a code assigned by the Client Organisation.  The format of the ID# is X [Last two digits of year of receipt] [Four digit Number].  For items received from a certain vendor, the last four digits of any item will always be in ascending order of the Date received.  In other words. for items received from a certain vendor, the last 4 digits of an item received on 13 January 2017 will always be greater than the last 4 digits of an item received on 11 January 2017 from the same vendor.  There will never be repetitions in the Item ID# column.

 Vendor Name Item ID# Date Received Error with Item? Error Category California X170016 1-16-2017 No California X170014 1-13-2017 Yes Labeling Error California X170015 1-13-2017 Yes Packaging Error California X170008 1-9-2017 Yes Quality Issue California X170003 1-2-2017 No California X160645 12-26-2016 Yes Packaging Error California X160646 12-26-2016 No California X160644 12-25-2016 Yes Labeling Error California X160638 12-20-2016 Yes Quality Issue California X160633 12-15-2016 No California X160626 12-8-2016 No California X160625 12-7-2016 Yes Packaging Error California X160624 12-5-2016 Yes Labeling Error California X160618 11-23-2016 Yes Quality Issue California X160613 11-13-2016 No California X160606 10-30-2016 No

The objective is to compute the error rate by vendor and Error category for the 10 most recent transaction dates with that specific vendor.  So, for vendor Name "California" and  Error category as "Packing Error", this ratio should be computed as = Number of packing Errors on 10 most recent dates/10.

Here is a simple snapshot of the Data for California.  I have filtered the dataset where Vendor Name is California and then sorted the Date received column in descending order.  Please note that when i filter the dataset on California, a lot more rows are returned.  I am only showing the Top 10 rows here because that is what is important for solving this question.

 Vendor Name Item ID# Date Received Error with Item? Error Category California X170016 1-16-2017 No California X170014 1-13-2017 Yes Labeling Error California X170015 1-13-2017 Yes Packaging Error California X170008 1-9-2017 Yes Quality Issue California X170003 1-2-2017 No California X160645 12-26-2016 Yes Packaging Error California X160646 12-26-2016 No California X160644 12-25-2016 Yes Labeling Error California X160638 12-20-2016 Yes Quality Issue California X160633 12-15-2016 No

The expected result is:

 Row Labels Labeling Error Packaging Error Quality Issue Factory Error Boise 30.00% California 20.00% 20.00% 20.00% Detroit 70.00% 30.00% Ekalaka 20.00% 20.00%

I have solved this problem using the PowerPivot. You may download my solution workbook from here.

Here is a simple 3 column dataset showing Categories, Date and Value

 Catagorie Date Value Fish 08-12-2015 6 Crab 05-12-2015 7 Crab 04-12-2015 6 Bird 27-11-2015 4 Snow 25-11-2015 10 Cat 21-11-2015 7 Dog 12-11-2015 5 Dog 28-10-2015 5 Fish 12-10-2015 3 Bird 11-10-2015 9 Dog 22-09-2015 9 Crab 17-08-2015 8 Cat 11-08-2015 1 Fish 20-07-2015 5 Crab 03-07-2015 2 Fish 02-06-2015 8 Fish 26-05-2015 9 Dog 14-05-2015 4 Snow 07-05-2015 7 Bird 03-05-2015 9 Cat 20-04-2015 10 Cat 15-04-2015 2 Snow 13-04-2015 3 Crab 29-03-2015 5 Crab 23-03-2015 2 Bird 14-03-2015 5 Cat 14-03-2015 1 Dog 26-02-2015 9 Fish 16-02-2015 4 Fish 08-02-2015 6 Bird 18-01-2015 1 Snow 06-01-2015 10

The objective is to compute category wise average of values against the 5 most recent dates.  So the expected result is:

 Categorie Category wise average values on 5 most recent dates Bird 5.60 Cat 4.20 Crab 5.60 Dog 6.40 Fish 6.20 Snow 7.50

So for the Category of Fish (dates are sorted in descending order), the average should be 6.2 (average of 6,3,5,8,9)

 Catagorie Date Value Fish 08-12-2015 6 Fish 12-10-2015 3 Fish 20-07-2015 5 Fish 02-06-2015 8 Fish 26-05-2015 9 Fish 16-02-2015 4 Fish 08-02-2015 6

I have solved this problem using the PowerPivot. You may download my solution workbook from here.

Here is a dataset showing Project wise forecast of open opportunities.

1. Topic is the Project Name
2. Est. Close Date is the date by when the opportunity would be closed i.e. the project would be won from that Client
3. Duration is the time (in months) for which the project would run
4. Amount is the total amount that would be billed for that project

Clients are invoiced annually only. So in the example below:

1. Project ABC is for US\$1 million with a duration of 24 months and is expected to be closed in Oct. 2017.  We need to model the data to show the billing every 12 months.  So for ABC US\$500K would be billed in Oct-2017 and another US\$500K in Oct-2018.
2. Project GEF is for US\$2 million with a duration of 18 months and is expected to be closed in Feb. 2018. We need to model the data to show US\$1.3 million in Feb-2018 and another US\$666K in Feb-2019.  The monthly billing is US\$2 million divided by 18 and then multiplied by 12 - this amounts to US\$1.3 million.
 Topic Est. Close Date Duration (Months) Amount ABC 01-10-2017 24 1,000,000 GEF 01-02-2018 18 2,000,000 XYZ 01-03-2018 30 1,000,000

The expected result should look like this:

 Row Labels Oct-17 Feb-18 Mar-18 Oct-18 Feb-19 Mar-19 Mar-20 Total ABC 500,000 500,000 1,000,000 GEF 1,333,333 666,667 2,000,000 XYZ 400,000 400,000 200,000 1,000,000 Grand Total 500,000 1,333,333 400,000 500,000 666,667 400,000 200,000 4,000,000

I have solved this problem using Power Query and PowerPivot. You may download my solution workbook from here.

Imagine a fixed monthly amount due to an Organisation for services rendered to various customers.  While an invoice is raised every month by this Organisation, not all pay up the dues on time.  For unpaid dues, the Organisation charges its client interest ranging from 3% to 9% per annum.  The objective is to determine cumulative interest payable by various customers to Organisation X.

The base data looks like this

 Client Monthly revenue Int. calculation start date Int. calculation end date Interest rate Client A 33,967 01-Aug-16 25-Jul-17 9.00% Client B 123 12-Sep-16 30-Nov-17 4.00%

Given the dataset above, the total interest payable by Client A is Rs. 16,237.20.  The calculation is shown below:

 From To Days for which interest should be paid Principal Interest 02-Aug-16 31-Aug-16 328.00 33,967.00 2,745.26 01-Sep-16 30-Sep-16 298.00 33,967.00 2,494.17 01-Oct-16 31-Oct-16 267.00 33,967.00 2,234.71 01-Nov-16 30-Nov-16 237.00 33,967.00 1,983.62 01-Dec-16 31-Dec-16 206.00 33,967.00 1,724.16 01-Jan-17 31-Jan-17 175.00 33,967.00 1,464.70 01-Feb-17 28-Feb-17 147.00 33,967.00 1,230.34 01-Mar-17 31-Mar-17 116.00 33,967.00 970.88 01-Apr-17 30-Apr-17 86.00 33,967.00 719.79 01-May-17 31-May-17 55.00 33,967.00 460.33 01-Jun-17 30-Jun-17 25.00 33,967.00 209.24 01-Jul-17 25-Jul-17 - 33,967.00 - Total 16,237.20

You may download my solution workbook with from here. I have solved this problem using normal Excel formulas and the PowerPivot.

Here is a dashboard created with a Pivot Table, a Pivot chart and slicers (Click to enlarge image).  In the Pivot Table, the % have been computed using "% of row total".

The Pivot chart shows two columns per month - one for complete and the other for incomplete.  The objective is to show only the Complete column per month in the Pivot chart.  If one filters the Pivot Table only on Complete, then the Pivot chart shows an unexpected result - each column will go upto 100%.  This happens because all calculations in a Pivot Table happen only on the visible cells.  Once the Incomplete column is hidden, the "% of row total" calculation will return 100% which in turn reflects in the Pivot chart.

I have resolved this problem with the help of the PowerPivot.  You may refer to my solution in this workbook.

Assume a dataset with two columns which lists down the student names in column A and courses opted for in column B.  Since one student can opt for multiple courses and the same course can be taken up by multiple students, there can be repetitions in both columns.  The objective is to create a matrix like data structure (with courses appearing in both row and column labels) with numbers inside the matrix quantifying the "Number of students who opted for course A and C".  So, for all possible course combinations, one may want to know the number of students who opted for those combinations.

The description above can be extended to cases where buying behavior has to be analysed.  A sore manager may want to know "How many people who buy Brand A also buy Brand B."

Here's a snapshot of the source data and expected result

The number 1 in cell H4 (and cell F6) means that there is only one student who opted for courses B and D.  Likewise, 3 in cell H5 (and cell G6) means that 3 students opted for courses C and D.

You may refer to my Power Query and PowerPivot solution in this workbook.  Power Query has been used for generating a dynamic list of Courses and Power Pivot has been used for writing the DAX formula for quantifying within the matrix.

Assume a two column dataset with Date in the first column and Price in the second one.  The purpose is to identify times to buy and sell - buying would be just after the lowest low is confirmed and sell before or just after the highest high is in place. Confirmation is achieved through crossover of moving averages. This data is being used in back testing buy and sell criteria.

Snapshot of base data

Snapshot of expected result

The Lowest Low is the lowest price that occurs before the next Highest High.  The Highest High is the highest price that occurs before the next Lowest Low..  2.77 is the lowest low after the highest high of 3.69 and 3.23 is highest high after the lowest low of 2.77.

You may refer to my solution in this workbook.

Assume a five column dataset - ID, Age, Gender, Time and Class.  For chosen ID's, the objective is to:

1. Assign a Rank (in ascending order of time i.e. lowest time will be rank 1 and so on) to each ID
2. Determine the overall place of each ID - Count of unique time entries lesser than equal to the chosen ID' time entry

These can be computed with the VLOOKUP(), RANK(), FREQUENCY(), INDIRECT() functions and array formulas.  You may refer to range H3:K8 of the Sample worksheet.  So far so good.

What adds to the problem is to meet the objectives outlined above after satisfying additional conditions.  For e.g., one may want to give conditions such as Age between 20 and 35 and colours as Orange and Yellow.  Carrying out computations for ranking and Overall place after satisfying these conditions will make the formulas fairly complex.

I have been able to solve this problem with the help of the PowerPivot.  You may download my solution workbook from this link.