With the new Extract expressions, are we currently able to extract a fraction from text?
@Daisy_Ramirez
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
etc.
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โ
@Daisy_Ramirez
How about
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!
@Daisy_Ramirez
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:
Nope.
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.
User | Count |
---|---|
41 | |
27 | |
27 | |
20 | |
13 |