Forum Discussion
aliadm1490
Jun 05, 2023Copper Contributor
How to find the difference between two text cells
Hi everyone and thanks for taking your time
Is there any software that can help extract the difference value between two text cells, like in the image below?
=TRIM(SUBSTITUTE(A2,B2,""))
- peiyezhuBronze Contributor=WEBSERVICE("https://e.anyoupin.cn/eh3/?regreplace~\s*(" & substitute(b2," ","|") & ")\s*~ ~" & A2)
- PeterBartholomew1Silver Contributor
This is just playing with 365. I set out to remove multiple space-separated sub-strings listed as 'secondary' from the corresponding 'main'
Worksheet formula = MAP(main, secondary, Removeλ) Removeλ = LAMBDA(string, sub, REDUCE(string, TEXTSPLIT(sub, " "), SUBSTλ)) SUBSTλ = LAMBDA(x, y, TRIM(SUBSTITUTE(x, y, "")))
- PatrickvSvBCopper Contributor
Hi PeterBartholomew1, This sounds exactly like something I currently need. Could you explain how to insert this into a cell / table column? Thanks a lot!
With kind regards,
Patrick
- PeterBartholomew1Silver Contributor
To keep the worksheet as clear as possible, I used
= MAP(Main, Secondary, Removeλ)
as the worksheet formula. I then used defined Names to refer to the two Ranges (a column of full texts strings and a column of strings to remove). The Lambda functions Removeλ and SUBSTλ are also defined using Name Manager or the AFE (Advanced Formula Editor).
If you prefer to minimise your use of Name Manager, an alternative exists of defining these LAMBDA functions within LET as a worksheet formula.
= LET( Removeλ, LAMBDA(string,sub, REDUCE(string, TEXTSPLIT(sub, " "), SUBSTλ)), SUBSTλ, LAMBDA(x,y, TRIM(SUBSTITUTE(x, y, ""))), MAP(Main, Secondary, Removeλ) )
If you are using Tables and Structured References, the references to the strings become
[@Main] and [@Secondary] and Removeλ can be used directly without the MAP.
You only need to make one of these work, but I do not know which you might prefer!
- Detlef_LewinSilver Contributor
=TRIM(SUBSTITUTE(A2,B2,""))
- aliadm1490Copper ContributorThanks You Saving My life 😍