EXTRACT - Can we Extract a fraction from text currently?

With the new Extract expressions, are we currently able to extract a fraction from text?

0 11 469
11 REPLIES 11

@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:

Steve
Platinum 4
Platinum 4

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.

Top Labels in this Space