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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
TheInvoker
Frequent Visitor

How to get value from JSON document record in M query (Power Connector)?

In M language (power connector), I download data and convert it to json like this

json = Json.Document(source)

I know for sure this json has 1 record like this

{Count: 3}

But If I return this, it shows 1 record like that. But as a test I changed it to return a number like 3 (hardcoded), and in power BI it showed just a value instead of a table. How can I return the value instead from the json document? Something like json[0]["Count"]?

1 ACCEPTED SOLUTION
jennratten
Super User
Super User

Hello - you were really close!

You should be seeing a list of records to convert the list to a table of records, on the ribbon, in the List tab, you can click Convert To Table. Then you can click the button in the column header to expand records.  If you'd like to access one record with a script, you can do so by referencing the element in the list and then values of the record's field.

If json is the name of the step in which you have a list containing one record:

Access the first element in the list:

json{0}

Access the value of the record's first field (quotes are not needed - if the name includes certian special characters then the name would need to be enclosed in #" "):

json{0}[Count]

 

let
    Source = Table.ToRecords(Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxkqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Id = _t])),
    Source1 = Source{0},
    Id = Source1[Id]
in
    Id

 

 

 

View solution in original post

1 REPLY 1
jennratten
Super User
Super User

Hello - you were really close!

You should be seeing a list of records to convert the list to a table of records, on the ribbon, in the List tab, you can click Convert To Table. Then you can click the button in the column header to expand records.  If you'd like to access one record with a script, you can do so by referencing the element in the list and then values of the record's field.

If json is the name of the step in which you have a list containing one record:

Access the first element in the list:

json{0}

Access the value of the record's first field (quotes are not needed - if the name includes certian special characters then the name would need to be enclosed in #" "):

json{0}[Count]

 

let
    Source = Table.ToRecords(Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxkqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Id = _t])),
    Source1 = Source{0},
    Id = Source1[Id]
in
    Id

 

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.