Forum Discussion
Splitting Tag data
- 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
One small thing if you use the custom-column version: your tags are wrapped in double quotes, so splitting on "," leaves them attached and the columns come out as "Portfolio with values like Generation 1". Trimming the quotes inside the transform fixes it:
List.Transform(Text.Split([Tags], ","), each Text.Trim(Text.Trim(_), """"))
BeaBF's step-by-step version already handles this with its Replace Values step.