Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi,
I'm trying to create a calculated column that extracts the country from a JSON string.
I don't have or want to create a Country table to select the country.
The source text is:
"{""FirstName"":""Myname"",""LastName"":""Mylastname"",""Email"":""not@not.com"",""Phone"":""1234455"",""Country"":""United States of America"",""Company"":""Global Trade"",""Title"":""Manager""}"
So in this case I want to extract 'United States of America' from the string.
I tried various options but it exits with the error "The search Text provided to function 'SEARCH' could not be found in the given text"
E.g.
Any hints?
Solved! Go to Solution.
Hi Dhairya,
Unfortunately the JSON is stored in an Azure Table Column, hence my approach.
I didn't see a way to pivot or split the column other than by delimiter which does not work very well.
BUT...your answer pointed me in the right direction.
I used "Transform / Parse as JSON" which turns the column into cells with records.
After this I created a new custom column that retrieves the records from the column.
E.g. for firstName I use:
= Table.AddColumn(#"Parsed JSON", "FirstName", each Record.Field([Content.CustomerInfo], "firstName"))
That retrieves the firstname value into my new custom column.
Thanks!
Roel
Hi Dhairya,
Unfortunately the JSON is stored in an Azure Table Column, hence my approach.
I didn't see a way to pivot or split the column other than by delimiter which does not work very well.
BUT...your answer pointed me in the right direction.
I used "Transform / Parse as JSON" which turns the column into cells with records.
After this I created a new custom column that retrieves the records from the column.
E.g. for firstName I use:
= Table.AddColumn(#"Parsed JSON", "FirstName", each Record.Field([Content.CustomerInfo], "firstName"))
That retrieves the firstname value into my new custom column.
Thanks!
Roel
Hey @leadmarlin
From your sample data, it is visible that the source is in JSON data format and you want to extract value corresponding to country, this task can be easily done using power query. Please follow the below steps to achieve it.
Step 1: Open Power Query Editor.
Step 2: Load the JSON File.
Step 3: Convert it to a Table.
Step 4: Pivot the Column.
Step 5: Remove Columns other than Country.
Now you can load this data into Power BI Desktop by clicking on Close and Apply button on top left corner.
Please refer to the following Advanced Editor Code, you have to just replace my source with yours.
let
Source = Json.Document(File.Contents("D:\sample.json")),
#"Converted to Table" = Record.ToTable(Source),
#"Pivoted Column" = Table.Pivot(#"Converted to Table", List.Distinct(#"Converted to Table"[Name]), "Name", "Value"),
#"Removed Other Columns" = Table.SelectColumns(#"Pivoted Column",{"Country"})
in
#"Removed Other Columns"
If this helps you then please kudo the post and mark it as accepted as solution so that others can find it quickly while facing the similar issue.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
84 | |
76 | |
73 | |
42 | |
36 |
User | Count |
---|---|
109 | |
56 | |
52 | |
48 | |
43 |