How to extract pattern from a cell in excel - excel

I have an excel file that contains data. There is one column that contains the description of payment and pay ID in each cell.
I want to extract only pay ID from each cell to the next column.
pay ID contains 12 digits in the form of 991xxxxxxxxx.
Here is a sample information contained in some of the cells:
Cell1 : 001 Cash Deposit - 0107 10:51:49 CMS NetworkID XXXPAY Control No 991110748686 KINFONCOMPANYLTD !! From
Cell2 : 118 Bill Payment - 0107 11:59:20 agency #22910013899#GEPG_PAY billctrlNo 991110748329 Phone Number 255779206080 Name
Cell3 : 521 Utility Payments - 0107 14:56:26 MPESAC2B GEPG_PAY billctrlNo 991110275410 Phone Number 255755914055 Name!! From M-PESA-NMB COLLECTION ACCOUNT =>
Cell4 : 372 Incoming Funds Transfer - Sender's Ref: FT21091ZGDM9 => Ordering Customer: /103895100026 * 1 Remittance Info: 991110557255
Cell5 : 118 Bill Payment - 0104 08:44:52 agency #31110037832# _PAY billctrlNo 991110531647 Phone Number 255676770771 Name
Cell6 : 521 Utility Payments - 0104 12:20:48 CMS NetworkID GEPGPAY Control No 991110650984 RKPHARMACEUTICALSTZLTD
Cell7 : 372 Incoming Funds Transfer - Sender's Ref: 005RTG210401016 => Ordering Customer: 0403901000 * VOCATIONAL TRAINING AUTHORITY => Remittance Info: 991110558261
Cell8 : 521 Utility Payments - 0104 19:29:45 _PAY billctrlNo 991110290890 Phone Number 25475244199
Cell9 : TMS GePG BIL:991110558959 AMANI CENTRE FOR STREET CHILDREN R REF:FB49141622529465
Cell10 : REF 2408853105211627 GEPG BIL 991110855155 TO AC 01J1028467503
Cell11 : CSM TISS GePG BIL:991110748443:REF:1622534049461198:001FTLC211520041:210601
Here is what i have done, but it's not effective on all cells.
=MID(B3,14,12)

You could try something like:
=Mid(B3,Find("991",B3),12)

Please try:
=MID(*CELL1*;FIND("991";*CELL1*;1);12)
"CELL1" refers to your cell that holds the text, for example "A1".

Try first to find the starting location of your PayID in the cell and extract than the whole PayID:
=MID(B3; FIND("991"; B3); 11)

Another possibility:
=LEFT(RIGHT(A1;LEN(A1)-FIND("991";A1));11)
works only if every pay id begins with 911 and there is no other "991" within the same row (especially before the pay id) and the number of digits is 11 (not 12!).

Related

Combining two queries in Power Query

I have the following two queries, one with a number of invoices sorted by date and the other one with a number of receipts
Customer ID
Trans. Type
Trans. Date
N#
Value
Fiscal Year
1
Invoice
03/07/2021
1
20.00
2021
1
Invoice
03/07/2020
2
10.00
2020
1
Invoice
14/01/2020
3
50.00
2020
1
Invoice
21/10/2019
4
200.00
2019
2
Invoice
01/10/2018
5
99.00
2018
Customer ID
Trans. Type
Trans. Date
N#
Value
1
Receipt
04/12/2020
50
260.00
1
Receipt
03/12/2020
49
110.00
My goal is to add one column to the receipt query with the fiscal year the invoice refers to, starting from the more recent ones until the receipt value is reached. The year must be taken from the "Fiscal Year" column.
The following would be the result I want to achieve.
Customer ID
Trans. Type
Trans. Date
N#
Value
Fiscal Year
1
Receipt
04/12/2020
50
11.00
2021
1
Receipt
04/12/2020
50
60.00
2020
1
Receipt
04/12/2020
50
189.00
2019
1
Receipt
03/12/2020
49
11.00
2019
1
Receipt
03/12/2020
49
99.00
2018
I would like to achieve this with M but the exercise is not trivial for me because the value of the receipt can refer to multiple invoices and I don't know how to split it.
EDIT
The second query can have multiple records because there can be several receipts over a period of time for the same customer.
All or part of the first query records can be included in the second query (there cannot be any receipt without having an invoice in first place).
EDIT 2
The process combine invoices and receipts of the same customers
The process also assumes that the invoices paid first are the older ones therefore the older invoices are used up first and the invoice balance left is used up by the next receipt.

MS Excel Extract all rows from a range based on conditions

i'm trying to extract all row from a range that meet my conditions, here is my table
Group
first name & last name
N°invoice
invoice Date
Excl. Tax
VAT
Incl. TAX
O.B
Rest
date of payment
A
Someone 01
10001
2022/01/01
1000
50
1050
paid
0
2022/01/15
B
Someone 02
10002
2022/01/01
1000
50
1050
Partial Paid
550
2022/01/14
A
Someone 01
10003
2022/01/10
1500
75
1575
Partial Paid
75
2022/01/15
C
Someone 03
10004
2022/01/10
1500
75
1575
paid
0
2022/01/15
I find in the internet a way to extract Rows of N°invoice based on one condition first name & last name After clicking CTRL + SHIFT and then swap down the formula
=INDEX($C$2:$C$04, SMALL(IF($B$10=$B$2:$B$04, ROW($B$2:$B$04)-ROW($C$2)+1), ROW(1:1)))
B10 is the cell that contain the name that im looking for.
i want to add one more condition so that it well extract by a certain first name & last name and Rest is
NOT equal to 0
i try
=INDEX($C$2:$C$04, SMALL(IF(AND($B$10=$B$2:$B$04,0<>$H$2:$N$145), ROW($B$2:$B$04)-ROW($C$2)+1), ROW(1:1)))
but it only extract the first row in the index

Excel formula count after certain observation in c horological order

I am having tough time building a logic around this problem for a while , Hope some one can help.
I have 3 column of data. Lets call them Customer ID , Call ID , Agent ID
Customer ID and Agent ID can have repetition however Call ID is unique .
Now i have a table with these columns- they are stacked in chronological order based on date or time. Also one customer can call multiple time to multiple agent generating unique caller ID every time.
Here i want to count number of time one customer has called after certain agent ID has received the call. So count or freq function will have to have a rule embedded in chronological function or "Count after certain rule has been met"
Below is the table
CusID CalID Agent
1 123 a
1 22 b
1 112 a
1 222 a
1 54 a
1 334 a
2 221 a
2 312 b
2 334 b
2 129 b
2 986 a
4 98 b
In above table i want to calculate number of observation for customer id '1'after he has called to agent 'b' so the answer will be 4. I have used couple of unique count based no multiple crietria using combination of sumif 1/countif however major problem is counting after certain observation.
can any one help
You can use this formula that will change the range to count to match where b is found the first time.
=COUNTIF(INDEX(A:A,AGGREGATE(15,6,ROW($C$2:$C$13)/(($C$2:$C$13=E3)*($A$2:$A$13=E2)),1)+1):$A$13,E2)

Converting text data into columns (excel)

My data is in the following format :
Tin : 07020182045
Dealer Name : VED RAM VEER SINGH
Dealer Address :C-195 GREATER KAILASH PART-I ,, NEW DELHI,
Ward : 88
Registration Type : VAT + CST
Return Frequency : Quarterly
Status : Cancelled
Registration Date : 01-04-2005
Tin : 07020202027
Dealer Name : GURDEEP SINGH & SONS
Dealer Address :IX/2265 GALI NO 10 KAILASH NAGAR ,, NEW DELHI 110051,
Ward : 78
Registration Type : VAT + CST
Return Frequency : Quarterly
Status : Cancelled
Registration Date : 01-04-2005
Will it be possible to convert it from paragraph format to columns ?
once you pasted your text into a column, you can go the menu item 'data' > text to columns > delimited > select 'other' and enter ":" without the quotes in the text box next to it. Then click finish and your text will now be in to columns.
if you need, you can also copy the columns and paste them transposed
You can perform text to column on the data, using ':' as delimiter. Text to column will then put tin in one column and 07020182045 in another column.

Index/match with two criteria anyway to get the second set of data using unique identifiers?

I've been stuck for some time trying to match up two different data spread sheets. I'm trying to match off dollar amounts with matching names that correspond to the dollar amount. I went ahead and assigned unique identifiers to each row thinking that would help me match off the amounts, but my problem comes when there are two or more dollar amounts that are the same and have the same name.. is there anyway to get the second id to show up?
Formula sheet: (I need The second 112 to pull 113.. anyway thats possible??
A B C D E F G
IDSheett2 IDsheet1 NameSheet1 NameSheet2 Item AmountSheet1 AmountSheet2
554 112 Jim Jim Hat 25 25
555 112 Jim Jim Shoe 25 25
Formula in column B2: it should go through both sheet 1 and 2 and automacially fill in the matching id - id that matches the name and amount.
=IFERROR(INDEX(sheet1!$C$2:$C$1000,MATCH(1,INDEX((sheet1!$A$2:$A$1000=D1)*(sheet1!$B$2:$B$1000=G1),0,1),0)),"")
Data from Sheet2:
A= ID B= Name C= Item Name ( ID basically row 1 = 1, 2 = 2.. )
A B C D
554 Jim Hat 25
555 jim Shoe25
Data from Sheet1:
A= name B= amount C= assigned ID ( ID basically row 1 = 1, 2 = 2.. )
A B C
Jim 25 112
Jim 25 113
I'm also open to other ideas. Thanks for the help.
UPdated::: Based on comments
im not trying to create a database.. i have two sets of data that i'm trying to compare and match off like items(i take matched items and email it out to a group of people). i had to change some of the names because this is work related but the overall concept should remain.
it is Impossible for me to know how many names will be on incoming wires and how many names will be on my expected wires lists. I assigned unique ids per row on each page so i can do iferror/index/match to pull from a unique row to the main page.
What im trying to accomplish:
I have two sets of data: Sheet1 is incoming wires (it gives me a name and an amount) Sheet 2 is the account name, Item its for, and expected amount.
I'm trying to match the name and amount on the formula sheet but i run into the problem of two items with the same name and the same amount only pulling the first ID number it runs into and this becomes a problem because i have another vba code that will delete multiple ID's so i know i'm not counting something twice.
my final page should read:
ID sheet2 IDsheet1 Name Item(sheet2) Amount
554 112 JIM Hat 25
555 113 JIM Shoe 25
but right now the 113 id wont pull and it will just be 112 twice (which will end up getting deleted so i will miss that second match)
..+ everything works perfectly unless there are two items for the same name and the same amount +.. that is the only time i run into this problem.
Is there any code or process that can have the sheet realize that it has already used the ID of 112 once and then automatically fill in the id of 113 (so it won't get deleted by my vba code)?
In your formula sheet, B2 and copied down:
=IFERROR(INDEX(Sheet1!$C$2:$C$1000,MATCH(1,INDEX((Sheet1!$A$2:$A$1000=D2)*(Sheet1!$B$2:$B$1000=G2)*(COUNTIF(B$1:B1,Sheet1!$C$2:$C$1000)=0),),0)),"")

Resources