<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Fetch value from JSON response in Power Query</title>
    <link>https://community.fabric.microsoft.com/t5/Power-Query/Fetch-value-from-JSON-response/m-p/4616466#M148305</link>
    <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;, Use this&lt;/P&gt;
&lt;P&gt;let&lt;BR /&gt;url = "&lt;A href="https://api.atlassian.com/jsm/assets/workspace/bcc5e987-a7e5-8398-8cc7-ea05j54479e9/v1/object/aql?st" target="_blank"&gt;https://api.atlassian.com/jsm/assets/workspace/bcc5e987-a7e5-8398-8cc7-ea05j54479e9/v1/object/aql?st&lt;/A&gt;...",&lt;BR /&gt;body = "{""qlQuery"": ""objectType = Servers""}",&lt;BR /&gt;Source = Json.Document(Web.Contents(&lt;BR /&gt;url, [&lt;BR /&gt;Headers = [#"Authorization" = "Basic &amp;lt;emailaddress:API token&amp;gt;", #"Content-Type" = "application/json"],&lt;BR /&gt;Content = Text.ToBinary(body)&lt;BR /&gt;]&lt;BR /&gt;)),&lt;BR /&gt;values = Source[values],&lt;BR /&gt;#"Converted to Table" = Table.FromList(values, Splitter.SplitByNothing(), null, null, ExtraValues.Error),&lt;BR /&gt;#"Expanded Column" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"objectKey", "attributes"}, {"objectKey", "attributes"}),&lt;BR /&gt;#"Added Custom" = Table.AddColumn(#"Expanded Column", "Server", each&lt;BR /&gt;let&lt;BR /&gt;attributes = [attributes],&lt;BR /&gt;filteredAttributes = List.Select(attributes, each _[objectTypeAttributeId] = "1235"),&lt;BR /&gt;firstMatch = if List.Count(filteredAttributes) &amp;gt; 0 then filteredAttributes else null,&lt;BR /&gt;value = if firstMatch &amp;lt;&amp;gt; null then firstMatch[objectAttributeValues][value] else null&lt;BR /&gt;in&lt;BR /&gt;value&lt;BR /&gt;)&lt;BR /&gt;in&lt;BR /&gt;#"Added Custom"&lt;/P&gt;</description>
    <pubDate>Wed, 19 Mar 2025 13:33:26 GMT</pubDate>
    <dc:creator>bhanu_gautam</dc:creator>
    <dc:date>2025-03-19T13:33:26Z</dc:date>
    <item>
      <title>Fetch value from JSON response</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Fetch-value-from-JSON-response/m-p/4616240#M148294</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I would like to fetch "red" value based on&amp;nbsp;"objectTypeAttributeId": "1235". Can anyone help me with the expression to fetch ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;JSON response:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"attributes": [&lt;BR /&gt;{&lt;BR /&gt;"workspaceId": "xxx-xxxx-xxxx-xxxx-xxxxxxxx",&lt;BR /&gt;"globalId": "xxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxxxx",&lt;BR /&gt;"id": "12345678",&lt;BR /&gt;"objectTypeAttributeId": "1234",&lt;BR /&gt;"objectAttributeValues": [&lt;BR /&gt;{&lt;BR /&gt;"value": "ABCD-1264",&lt;BR /&gt;"searchValue": "ABCD-1264",&lt;BR /&gt;"referencedType": false,&lt;BR /&gt;"displayValue": "ABCD-1264"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"objectId": "1264533"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"workspaceId": "xxx-xxxx-xxxx-xxxx-xxxxxxxx",&lt;BR /&gt;"globalId": "xxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxxxx",&lt;BR /&gt;"id": "12345687",&lt;BR /&gt;"objectTypeAttributeId": "1235",&lt;BR /&gt;"objectAttributeValues": [&lt;BR /&gt;{&lt;BR /&gt;"value": "Red",&lt;BR /&gt;"searchValue": "Red",&lt;BR /&gt;"referencedType": false,&lt;BR /&gt;"displayValue": "Red"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"objectId": "1264533"&lt;BR /&gt;},&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My query snippet:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#"Added Custom" = Table.AddColumn(#"Expanded Column", "Name", each [attributes]{&lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;}[objectAttributeValues]{0}[value]),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Result :&lt;/U&gt; "Red" &lt;EM&gt;(but need this value based on&amp;nbsp;objectTypeAttributeId)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; is hard-coded. I believe this has to be replaced with &amp;lt;"objectTypeAttributeId": "1235"&amp;gt; condition. So that the value will be fetched properly irrespective of the placement in the response.&lt;/P&gt;&lt;P&gt;I am not sure how to do that.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if you need more details.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2025 12:24:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Fetch-value-from-JSON-response/m-p/4616240#M148294</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-03-19T12:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch value from JSON response</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Fetch-value-from-JSON-response/m-p/4616412#M148302</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;, Try using&lt;/P&gt;
&lt;P&gt;#"Added Custom" = Table.AddColumn(#"Expanded Column", "Name", each &lt;BR /&gt;let&lt;BR /&gt;attributes = [attributes],&lt;BR /&gt;filteredAttributes = List.Select(attributes, each _[objectTypeAttributeId] = "1235"),&lt;BR /&gt;firstMatch = if List.Count(filteredAttributes) &amp;gt; 0 then filteredAttributes else null,&lt;BR /&gt;value = if firstMatch &amp;lt;&amp;gt; null then firstMatch[objectAttributeValues][value] else null&lt;BR /&gt;in&lt;BR /&gt;value&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2025 13:03:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Fetch-value-from-JSON-response/m-p/4616412#M148302</guid>
      <dc:creator>bhanu_gautam</dc:creator>
      <dc:date>2025-03-19T13:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch value from JSON response</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Fetch-value-from-JSON-response/m-p/4616450#M148304</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="625922" data-lia-user-login="bhanu_gautam" class="lia-mention lia-mention-user"&gt;bhanu_gautam&lt;/a&gt;&amp;nbsp;for your resonse.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting below error while using your code.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Expression.Error: We cannot apply field access to the type List.&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Details:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Value=[List]&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Key=objectAttributeValues&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I missed you mention in my previous post that this JSON response has lot attributes like I have mentioned. I just posted for one such instance.&lt;/P&gt;&lt;P&gt;Meaning that there is one &lt;SPAN&gt;&lt;EM&gt;[objectTypeAttributeId] = "1235"&lt;/EM&gt; for the all attributes listed. Just that we not sure about its position within one attribute list.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here is my full code - hope this will be more clearer&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;let&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;url = "&lt;A href="https://api.atlassian.com/jsm/assets/workspace/bcc5e987-a7e5-8398-8cc7-ea05j54479e9/v1/object/aql?startAt=0&amp;amp;maxResults=15000&amp;amp;includeAttributes=true" target="_blank"&gt;https://api.atlassian.com/jsm/assets/workspace/bcc5e987-a7e5-8398-8cc7-ea05j54479e9/v1/object/aql?startAt=0&amp;amp;maxResults=15000&amp;amp;includeAttributes=true&lt;/A&gt;",&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;body = "{""qlQuery"": ""objectType = Servers""}",&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Source = Json.Document(Web.Contents(&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;url,[ &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Headers=[#"Authorization"="Basic &amp;lt;emailaddress:API token&amp;gt;",#"Content-Type"="application/json"],&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Content=Text.ToBinary(body)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;]&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;values = Source[values],&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;#"Converted to Table" = Table.FromList(values, Splitter.SplitByNothing(), null, null, ExtraValues.Error),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;#"Expanded Column" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"objectKey", "attributes"}, {"objectKey", "attributes"}),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;#"Added Custom" = Table.AddColumn(#"Expanded Column", "Server", each &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;let&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;attributes = [attributes],&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;filteredAttributes = List.Select(attributes, each _[objectTypeAttributeId] = "1235"),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;firstMatch = if List.Count(filteredAttributes) &amp;gt; 0 then filteredAttributes else null,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;value = if firstMatch &amp;lt;&amp;gt; null then firstMatch[objectAttributeValues][value] else null&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;in&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;value)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;in&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;#"Added Custom"&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;img /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2025 13:29:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Fetch-value-from-JSON-response/m-p/4616450#M148304</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-03-19T13:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch value from JSON response</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Fetch-value-from-JSON-response/m-p/4616466#M148305</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;, Use this&lt;/P&gt;
&lt;P&gt;let&lt;BR /&gt;url = "&lt;A href="https://api.atlassian.com/jsm/assets/workspace/bcc5e987-a7e5-8398-8cc7-ea05j54479e9/v1/object/aql?st" target="_blank"&gt;https://api.atlassian.com/jsm/assets/workspace/bcc5e987-a7e5-8398-8cc7-ea05j54479e9/v1/object/aql?st&lt;/A&gt;...",&lt;BR /&gt;body = "{""qlQuery"": ""objectType = Servers""}",&lt;BR /&gt;Source = Json.Document(Web.Contents(&lt;BR /&gt;url, [&lt;BR /&gt;Headers = [#"Authorization" = "Basic &amp;lt;emailaddress:API token&amp;gt;", #"Content-Type" = "application/json"],&lt;BR /&gt;Content = Text.ToBinary(body)&lt;BR /&gt;]&lt;BR /&gt;)),&lt;BR /&gt;values = Source[values],&lt;BR /&gt;#"Converted to Table" = Table.FromList(values, Splitter.SplitByNothing(), null, null, ExtraValues.Error),&lt;BR /&gt;#"Expanded Column" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"objectKey", "attributes"}, {"objectKey", "attributes"}),&lt;BR /&gt;#"Added Custom" = Table.AddColumn(#"Expanded Column", "Server", each&lt;BR /&gt;let&lt;BR /&gt;attributes = [attributes],&lt;BR /&gt;filteredAttributes = List.Select(attributes, each _[objectTypeAttributeId] = "1235"),&lt;BR /&gt;firstMatch = if List.Count(filteredAttributes) &amp;gt; 0 then filteredAttributes else null,&lt;BR /&gt;value = if firstMatch &amp;lt;&amp;gt; null then firstMatch[objectAttributeValues][value] else null&lt;BR /&gt;in&lt;BR /&gt;value&lt;BR /&gt;)&lt;BR /&gt;in&lt;BR /&gt;#"Added Custom"&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2025 13:33:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Fetch-value-from-JSON-response/m-p/4616466#M148305</guid>
      <dc:creator>bhanu_gautam</dc:creator>
      <dc:date>2025-03-19T13:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch value from JSON response</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Fetch-value-from-JSON-response/m-p/4616490#M148307</link>
      <description>&lt;P&gt;Thanks again!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting the same error.&lt;/P&gt;&lt;P&gt;Moreover, I am not sure what was the change you did in my code. Can you please highlight ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2025 13:40:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Fetch-value-from-JSON-response/m-p/4616490#M148307</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-03-19T13:40:14Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch value from JSON response</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Fetch-value-from-JSON-response/m-p/4616521#M148308</link>
      <description>&lt;P&gt;&lt;SPAN&gt;A complete test code, please pay attention to the comments:&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;let
    data = Json.Document("{
        ""attributes"": [
            {
                ""workspaceId"": ""xxx-xxxx-xxxx-xxxx-xxxxxxxx"",
                ""globalId"": ""xxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxxxx"",
                ""id"": ""12345678"",
                ""objectTypeAttributeId"": ""1234"",
                ""objectAttributeValues"": [
                    {
                        ""value"": ""ABCD-1264"",
                        ""searchValue"": ""ABCD-1264"",
                        ""referencedType"": false,
                        ""displayValue"": ""ABCD-1264""
                    }
                ],
                ""objectId"": ""1264533""
            },
            {
                ""workspaceId"": ""xxx-xxxx-xxxx-xxxx-xxxxxxxx"",
                ""globalId"": ""xxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxxxx"",
                ""id"": ""12345687"",
                ""objectTypeAttributeId"": ""1235"",
                ""objectAttributeValues"": [
                    {
                        ""value"": ""Red"",
                        ""searchValue"": ""Red"",
                        ""referencedType"": false,
                        ""displayValue"": ""Red""
                    }
                ],
                ""objectId"": ""1264533""
            }
        ]
    }"),
    data2 = Json.Document("{
        ""attributes"": [
            {
                ""workspaceId"": ""xxx-xxxx-xxxx-xxxx-xxxxxxxx"",
                ""globalId"": ""xxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxxxx"",
                ""id"": ""12345678"",
                ""objectTypeAttributeId"": ""1234"",
                ""objectAttributeValues"": [
                    {
                        ""value"": ""ABCD-1264"",
                        ""searchValue"": ""ABCD-1264"",
                        ""referencedType"": false,
                        ""displayValue"": ""ABCD-1264""
                    }
                ],
                ""objectId"": ""1264533""
            }
        ]
    }"),
    #"Expanded Column" = #table({"Col"}, {{data}, {data2}}),
    #"Added Custom" = Table.AddColumn(
        #"Expanded Column", 
        "Name", 
        // Replace [Col] with the actual column name
        each List.Select([Col][attributes], each [objectTypeAttributeId] = "1235"){0}?[objectAttributeValues]?{0}?[searchValue]?
    )
in
    #"Added Custom"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2025 13:50:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Fetch-value-from-JSON-response/m-p/4616521#M148308</guid>
      <dc:creator>ZhangKun</dc:creator>
      <dc:date>2025-03-19T13:50:57Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch value from JSON response</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Fetch-value-from-JSON-response/m-p/4616624#M148315</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="516515" data-lia-user-login="ZhangKun" class="lia-mention lia-mention-user"&gt;ZhangKun&lt;/a&gt;. It worked!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2025 14:32:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Fetch-value-from-JSON-response/m-p/4616624#M148315</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-03-19T14:32:46Z</dc:date>
    </item>
  </channel>
</rss>

