With the new Extract expressions, are we currently able to extract a fraction from text?
Can you exemplify?
Hi Levent, no problem. I have recipes downloaded that provide a full line of text for the required ingredients:
1/2 cup of whole milk
1 tsp of salt
I’m not so clear what or what part do you want to extract from your provided example
Need to extract the fraction from the text:
For “1/2 cup of whole milk”
the result should be “1/2”
INDEX( SPLIT( [ColumnName], " " ), 1 )
I’ll give it try! Thanks Levent
I’m sure you are probably already aware of this article describing the EXTRACT() function, but just in case I have included it below.
It does not mention or hint that it can extract fractional text. But I wonder if the DATES specifier might work since the fractions you are likely to encounter could also be Dates without the year? Haven’t tried so not sure.
@LeventK solution is perfect, IF you know the fractions will always be the first “word” in the text.
Yes - I was hoping EXTRACT() already had the capability Thanks John!
Provided it is not a must to write it as fractions (1/2), provided you write them as decimals (1.5), you can use this:
In the case of a recipe app where you want common fractions to show up (i.e. 1/4, 1/2), maybe you could create a helper table which relates the decimal format to the fractional format, and utilize SUBSTITUTE()? this may simplify some of the formatting challenges you could encounter.