Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

MailChimp API - Expression Error 'field' of the record not found

Working with the MailChimp API and a field called "list_stats" didn't come through on a few records from the Campaign Summary. Unfortunatly I can't figure out how to transform the table prior to expanding.

 

I've tried

Table.ExpandColumns() without listing 'list_stats' in the function arguements but it still gave errors.

 

I tried to combine some learnings from this blog post  and another from this post. But this codes doesn't work because I'm not trying to transform a List but a Table

Table.TransformColumns(#"Filtered Rows",{{"Data", each List.Transform(_, each Record.SelectFields(_,{"list_stats"},MissingField.UseNull))}})

 

So far I have the basic stuff 

let
Source = MailChimp.TablesV2(),
campaigns = Source{[Key="campaigns"]}[Data],
#"Filtered Rows" = Table.SelectRows(campaigns, each ([Name] = "Campaign Summary")),
#"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"Data"}),
Data = #"Removed Other Columns"{0}[Data],

 

 

 

 

I know that @MarcelBeu could answer this but I may have used up my help requests for the week.

  • Anonymous's avatar
    Anonymous
    8 years ago

    For now, I modified the query...instead of pulling the Campaign Summary UI endpoint I leveraged the Instance function

     

    = #"MailChimp Instance"("/reports?since_send_time=2014-01-01&count=500")

     

    It gives me the same number of results after I remove the error rows and the rows with "sent_time" = blank

5 Replies

  • v-qiuyu-msft's avatar
    v-qiuyu-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous,

     

    Can you share the results of the step "#"Removed Other Columns""? It seems the issue is the value can't be changed to record type. 

     

    You can use below Query to check 14th row, if any column values different from others. 

     

    let
    Source = MailChimp.TablesV2(),
    #"Filtered Rows" = Table.SelectRows(Source, each ([Name] = "Campaigns"))[Data]{0}
    in
    #"Filtered Rows"

     

    Maybe ImkeF MarcelBeug have another good suggestions. 

     

    Best Regards,
    Qiuyun Yu 

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hey v-qiuyu-msft

       

      I modified the code slightly to pull just the campaign summary: = Table.SelectRows(Source, each ([Name] = "Campaign Summary"))[Data]{0}

       

      but receive the error message "Expression Error: There weren't enough elements in the enumeration to complete the operation. Details: List"

       

      The result of the Removed Other Columns is just a sigle table with The Data field and one value as Table, then if you try to expand the table you get the second screen shot with row 14 showing error. 

       

       

      Some how it needs to modify all records in the table to include the "list_stats" if it doesn't already have it

      • Anonymous's avatar
        Anonymous
        Not applicable

        For now, I modified the query...instead of pulling the Campaign Summary UI endpoint I leveraged the Instance function

         

        = #"MailChimp Instance"("/reports?since_send_time=2014-01-01&count=500")

         

        It gives me the same number of results after I remove the error rows and the rows with "sent_time" = blank