1
{"c": "4343434", "d": "m", "k": "+la+la", "l": "40990", "m": "b", "n": "o",
"p": "{adposition}", "s": "b", "dm": "{devicemodel}", "adc": "{creative}", 
"adg": "454554545454", "src": "hahahah45", "tid": "kwd-utututututu", 
"utm_term": "+ka +ka", "utm_medium": "cpc"}

I am trying to extract the section "s":"b" into a new column in a Power Query query. I know this comes down to escaping and I've read the official documentation of the M formula language but I just don't get how to extract this using the text formulas only. How can I do this?

2
  • What are the rules for extracting the piece you want? Everything between "{adposition}", and "{devicemodel}"? May 22, 2018 at 16:40
  • @alexisolson - Hi, not really, I only need what s is, in this case s is b, so basically if I could get "s": "b" as a result that would be good enough May 23, 2018 at 20:11

2 Answers 2

0

@ShiYang has key function needed.

If you have a table where a column called Text where each row has text like in your post, then you can write a custom column that extracts the value belonging to s using the following formula:

= Json.Document([Text])[s]

This takes the text in column [Text] and reads it as JSON and extracts the s component.


The full step code looks like this:

= Table.AddColumn(#"Preveious Step", "Custom", each Json.Document([Text])[s])
1
  • That worked perfectly. You are a life saver! You really taught me something here, much appreciated. May 24, 2018 at 13:16
0

You can use Json.Document to parse Json。

let
    Source = "{""c"": ""4343434"", ""d"": ""m"", ""k"": ""+la+la"", ""l"": ""40990"", ""m"": ""b"", ""n"": ""o"", ""p"": ""{adposition}"", ""s"": ""b"", ""dm"": ""{devicemodel}"", ""adc"": ""{creative}"", ""adg"": ""454554545454"", ""src"": ""hahahah45"", ""tid"": ""kwd-utututututu"", ""utm_term"": ""+ka +ka"", ""utm_medium"": ""cpc""}",
    Result = Json.Document(Source)[s]
in
    Result
1
  • this looks great but I need this as a new column in an existing query, there's more things going on in the query than just extracting this, it should be just one of the steps resulting in a new column. Thanks for your last response though! May 22, 2018 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.