Forum Discussion

masplin's avatar
masplin
Impactful Individual
2 years ago
Solved

Tricky text extraction in Power Query

Hi   I have a data string [Latest Financials] that looks like this   {'vat': ['20.00', '85.26'], 'share': {'price': '426.31', 'num_parties': 4}, 'total': '511.57', 'subtotal': '1705.24', 'drug_te...
  • bhanu_gautam's avatar
    2 years ago

    masplin < Try using this m-code in custom column

     

    = Table.AddColumn(#"PreviousStepName", "Drug Test Fee", each
    let
    sourceText = [Latest Financials],
    startPos = Text.PositionOf(sourceText, "drug_test_fees"),
    afterKey = Text.Middle(sourceText, startPos + Text.Length("drug_test_fees") + 4),
    feeText = Text.BeforeDelimiter(afterKey, ",")
    in
    if startPos > 0 then Text.Trim(Text.Select(feeText, {"0".."9", "."})) else null
    )