Need help creating a multi-variable formula with conditional logic

mgreenfi

New Member
Joined
Dec 19, 2016
Messages
1
On a reoccurring basis I'm given a large amount of raw date in Excel and asked to produce metrics on it. Some of the reports are repetitive while others are one time requests, all of them can be time consuming. To aid I'm trying to automate parts of this task but need help.

Below is a mocked out subset of data that I am given. Using the information in the Raw Data section I need to create what you see in the Desired Data section, which is a report that will tell me all the companies that we flagged as having borrowed sorted by date. The part that is stumping me is the the fact that the company names are never consistent so i need to first dynamically pull and list all unique company names. I then have to determine how many times on a given date that company had an action of 'Borrow' and display that sum, i.e Company XYZ was flagged with an action of 'Borrow' 2 times on 4 Dec.

ABCDE
1Raw Data
2Company
InputOutputActionDate
3ABCAppleOrangebuy1-Dec
4ABCAppleOrangeborrow 1-Dec
5ABCPearApplesell1-Dec
6XYZPearAppleborrow 1-Dec
7ABCAppleOrangebuy2-Dec
8LMNOrangePearsell2-Dec
9XYZOrangePearborrow 2-Dec
10XYZOrangePearsell2-Dec
11ABCPearAppleborrow 4-Dec
12LMNOrangePearborrow 4-Dec
13XYZApplePearborrow 4-Dec
14XYZOrangePearborrow 4-Dec
15
16
17
18
Desired Data
19Date
CompanyBorrowers
201-DecABC1
211-DecXYZ1
222-DecXYZ1
234-DecABC1
244-DecLMN1
254-DecXYZ2

<colgroup><col><col><col span="4"></colgroup><tbody>
</tbody>
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
In A18 control+shift+enter, not just enter:

=SUM(IF(FREQUENCY(IF(1-($A$3:$A$14&$E$3:$E$14=""),IF($D$3:$D$14="borrow",MATCH($A$3:$A$14&$E$3:$E$14,$A$3:$A$14&$E$3:$E$14,0))),ROW($A$3:$A$14)-ROW($A$3)+1),1))

In A20 control+shift+enter, not just enter, and copy down:

=IF(ROWS($A$20:A20)>$A$18,"",INDEX($E$3:$E$14,SMALL(IF(FREQUENCY(IF(1-($A$3:$A$14&$E$3:$E$14=""),IF($D$3:$D$14="borrow",MATCH($A$3:$A$14&$E$3:$E$14,$A$3:$A$14&$E$3:$E$14,0))),ROW($A$3:$A$14)-ROW($A$3)+1),ROW($A$3:$A$14)-ROW($A$3)+1),ROWS($A$20:A20))))

In B20 control+shift+enter, not just enter, and copy down:

=IF(ROWS($A$20:A20)>$A$18,"",INDEX($A$3:$A$14,SMALL(IF(FREQUENCY(IF(1-($A$3:$A$14&$E$3:$E$14=""),IF($D$3:$D$14="borrow",MATCH($A$3:$A$14&$E$3:$E$14,$A$3:$A$14&$E$3:$E$14,0))),ROW($A$3:$A$14)-ROW($A$3)+1),ROW($A$3:$A$14)-ROW($A$3)+1),ROWS($A$20:A20))))

In C20 just enter and copy down:

=COUNTIFS($E$3:$E$14,$A20,$A$3:$A$14,$B20,$D$3:$D$14,"borrow")
 
Upvote 0

Forum statistics

Threads
1,214,821
Messages
6,121,759
Members
449,048
Latest member
excelknuckles

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