Parse text from large string
@Paul Newcome - I've read a lot of your discussions throughout the years and you are the MAN! I have a question down below and hoping you can walk me through it. I'm simply not that good at this particular formula design.
I have a SF Connector setup and it pulls the below string. The total character length of the string is seldom the same for each row that comes in. I'm trying to parse certain information from this string. I feel like if I can get the formula down, I'd be off to the races.
To start, I just need (for now) the SUBTOTAL (which in the case below should be 630. Basically I need to find the subtotal, and then parse out the value (630).
{"PurchaseOrder" : {"@timeStamp":"2021-12-29 12:44:28","Request":{"Payment":{"@method":"AB"},"OrderType":"NC","Detail":{"Totals":{"Total":"576.19","SubTotal":"630","Delivery":"0"},"Item":[{"VendorPack":"1","VendorID":"01234567","Units":"1","UnitPrice":"630.0","UnitOfMeasure":"EA","Taxable":"Y","Sku":"987654321","QuoteID":"Channel","Qty":"1","MerchClass":"635","ManufacturerPartNum":"01-00860-101","ManufacturerID":"000123456","ListPrice":"699.99","LineNumber":"1","Description":"XXXXX","CustomerLineNumber":"1","CostCenter":"","Cost":"576.19","CatalogPage":""}]},"Accounting":{"Release":"","PONumber":{"*body":"PO12345"},"Desktop":"","CostCenter":""}},"Header":{"ShipTo":{"Addr":{"@seq":"00003","Contact":{"PhoneNumber":{"Number":"(000) 000-0000"},"Name":"JOHN SMITH","Email":{"*body":"johnsmith@gmail.com"}}}},"ShipComplete":"N","Sender":"SalesForce","Returnable":"N","DropShip":"Y","CustomerID":"012345678","Comments":"No Comments","BillOnly":"N"},"@documentid":"a8t2S000001ZjHEQA0"}}
Best Answer
-
Sorry my mistake the 160 shouldn't have been there it should have been start@row
Nested =MID(Text@row, FIND("SubTotal", Text@row, 1) + 11, FIND(CHAR(34), Text@row, FIND("SubTotal", Text@row, 1) + 11) - (FIND("SubTotal", Text@row, 1) + 11))
Answers
-
I did helper columns but you could nest it
Start =FIND("SubTotal", Text@row, 1) + 11
Length =(FIND(CHAR(34), Text@row, 160)) - Start@row
Subtotal =MID(Text@row, Start@row, Length@row)
-
It wasn't working until I replaced the "160" from your LENGTH equation with Start@Row. Then it worked FLAWLESSLY!!!!
What would a nested version of this look like? (I'm sorry I'm a bit of a noob when it comes to the equation side of the platform -- I've got dashboards and portals and workflows and automations covered, but I'm two left feet with complex nesting)
-
Sorry my mistake the 160 shouldn't have been there it should have been start@row
Nested =MID(Text@row, FIND("SubTotal", Text@row, 1) + 11, FIND(CHAR(34), Text@row, FIND("SubTotal", Text@row, 1) + 11) - (FIND("SubTotal", Text@row, 1) + 11))
-
That's pretty much how I would have done it as well.
-
SWEET! Thank you so much Paul I appreciate it!
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.8K Get Help
- 434 Global Discussions
- 138 Industry Talk
- 470 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 65 Community Job Board
- 486 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!