Forum Discussion

dommyw277's avatar
dommyw277
Icon for Helper V rankHelper V
11 days ago
Solved

Splitting Tag data

Hi How do I split columns of tags we have? As an example , one string might be: "Portfolio:Generation 1","Created Date: 01/01/2021","Product:Test1", etc etc and the second string might be: "Create...
  • BeaBF's avatar
    BeaBF
    9 days ago

    dommyw277​ Try with:

    let

    Source = AzureCostManagement.Tables("Enrollment Number", "REDACTED", 12, [startDate=null, endDate=null]),

    usagedetails = Source{[Key="usagedetails"]}[Data],

     

    // Read the Tags text as JSON and turn it into a record (name/value pairs)

    ParsedTags = Table.AddColumn(usagedetails, "TagRecord", each

    let

    t = if [Tags] = null then "" else Text.Trim([Tags]),

    j = if Text.StartsWith(t, "{") then t else "{" & t & "}",

    r = try Json.Document(j) otherwise null

    in

    if r is record then r else null,

    type nullable record),

     

    // One column per tag. List the tag names you need, spelled exactly as in the data

    ExpandedTags = Table.ExpandRecordColumn(ParsedTags, "TagRecord",

    {"Creator", "Portfolio", "Created Date", "Product"})

    in

    ExpandedTags