Forum Discussion

Moore55's avatar
Moore55
Regular Visitor
1 year ago
Solved

How to pull real value from a column containing an key value array

I am working on a report using a database that effectively contains data from a bunch of questions and answers   The problem i am encountering is the value being saved into the answer column is the...
  • v-dineshya's avatar
    1 year ago

    HI Moore55 ,

    Thank you for reaching out to the Microsoft Community Forum.

     

    Use this M code in the custom column formula:

    let
    optionsText = Text.Middle([Options], 1, Text.Length([Options]) - 2), // remove outer braces
    optionsList = Text.Split(optionsText, ", "),
    optionsRecord = Record.FromList(
    List.Transform(optionsList, each Text.Trim(Text.AfterDelimiter(_, ":"))),
    List.Transform(optionsList, each Text.Trim(Text.BeforeDelimiter(_, ":")))
    )
    in
    Record.FieldOrDefault(optionsRecord, [Answer], null)

     

    If my response has resolved your query, please mark it as the Accepted Solution to assist others. Additionally, a 'Kudos' would be appreciated if you found my response helpful.

    Thank you