Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
jamienourish
Frequent Visitor

Extract string from json object/array when using DirectQuery mode

Hi,

 

How can I extract a string from this json, when using DirectQuery mode.

 

I either have 1 object

{"label":"a label","value":"a value"}

and would like to pull out the value.

 

or an array 


[{"label":"1st label","value":"1st value"},{"label":"2nd label","value":"2nd value"}]

and would like to pull out all values

e.g. "1st value, 2nd value"

 

Thank you

1 ACCEPTED SOLUTION

Hi @jamienourish,

 

If all the strings have the same format, please try out the formulas below as calculated columns. The functions we can use are limited due to the limitation of Direct Query. 

FirstValue =
VAR startNum =
    FIND ( """value"":", [json_filed], 1, 9999 ) + 9
VAR chars =
    FIND ( """}", [json_filed], 1, 9999 ) - startNum
RETURN
    MID ( [json_filed], startNum, chars )
SecondValue =
VAR firstPosition =
    FIND ( """value"":", [json_filed], 1, 9999 ) + 9
VAR secondPosition =
    FIND ( """value"":", [json_filed], firstPosition, 9999 ) + 9
VAR chars =
    FIND ( """}]", [json_filed], 1, 9999 ) - secondPosition
RETURN
    IF (
        FIND ( "[", [json_filed], 1, 9999 ) <> 9999,
        MID ( [json_filed], secondPosition, chars ),
        BLANK ()
    )

Extract-string-from-json-objectarray-when-using-Direct-Query-mode2

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @jamienourish,

 

Could you please provide more details?

What's the data source?

Where does the JSON object store?

Do the JSON objects have the same length and the same format?

 

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks for replying,

 

Yes the database has a generic column that is a string, and power bi is connected to that using directquery.

 

in the column I store json that looks like above. 

 

I just need to extract the value from that string

Hi @jamienourish,

 

If all the strings have the same format, please try out the formulas below as calculated columns. The functions we can use are limited due to the limitation of Direct Query. 

FirstValue =
VAR startNum =
    FIND ( """value"":", [json_filed], 1, 9999 ) + 9
VAR chars =
    FIND ( """}", [json_filed], 1, 9999 ) - startNum
RETURN
    MID ( [json_filed], startNum, chars )
SecondValue =
VAR firstPosition =
    FIND ( """value"":", [json_filed], 1, 9999 ) + 9
VAR secondPosition =
    FIND ( """value"":", [json_filed], firstPosition, 9999 ) + 9
VAR chars =
    FIND ( """}]", [json_filed], 1, 9999 ) - secondPosition
RETURN
    IF (
        FIND ( "[", [json_filed], 1, 9999 ) <> 9999,
        MID ( [json_filed], secondPosition, chars ),
        BLANK ()
    )

Extract-string-from-json-objectarray-when-using-Direct-Query-mode2

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

You have saved me hours, thank you very much

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors