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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
lachlanP
Helper II
Helper II

Selecting a component of a record based on another column

I have a column, "JSON" where each field is a record, and another column "ref1" which holds a reference to the JSON record. In this example it's just the text "accel" (one of the elements in the json record), but in practice each row would be different.

lachlanP_0-1654890875811.png

I am trying to create a new column which pulls out the "accel" value from the json array. This is what Ive tried:

lachlanP_1-1654890957032.png

But the problem is, it is looking for the value "A", not the value the variable holds, which is [ref1] or "accel".

lachlanP_2-1654891016807.png

 

Is there a way to use the square brackets selector to pick an element in the record, but use some sort of syntax to insert the actual value of my variable in? Something like:

A = [ref1]

element = [JSON][[A]] or

element = [JSON][#"A"]

 

where it references the value of the variable A, not the string "A".

 

Thank you!

1 ACCEPTED SOLUTION
lachlanP
Helper II
Helper II

I figured out a solution. Instead of referencing using:

element = [JSON][A]

I used:

Record.Field([JSON],[A])

 

This worked!

View solution in original post

1 REPLY 1
lachlanP
Helper II
Helper II

I figured out a solution. Instead of referencing using:

element = [JSON][A]

I used:

Record.Field([JSON],[A])

 

This worked!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors