Forum Discussion

AAAAOps's avatar
AAAAOps
Frequent Visitor
8 years ago
Solved

Expression.Error: We cannot convert a value of type Table to type List.

Hello All, We are completely new to Power BI and trying to integrate with Dynamics 365 Data. We have had some success but are hitting a very confusing stumbling block. I have imported data from...
  • MarcelBeug's avatar
    MarcelBeug
    8 years ago

    At least now I know the cause of the error.

     

    In the rename step you provide a table name - #"Expanded Customer Health"  - as the second parameter for function Table.RenameColumns, while the second parameter should be the list with renames (which you provided as the 3rd parameter).

     

    Please note that the query will only create 1 table, so if you merge your Accounts with both the RelationshipOptionSet and the CustomerHealthOptionSet, then you will get 1 table that includes the cartesian product of the nested tables.

     

    Example:

    if, for 1 Account, you have 3 rows in RelationshipOptionSet and 4 records in CustomerHealthOptionSet, then you will end up with 3 x 4 = 12 rows for that Account, after expanding the nested tables.

     

    Possibly that is not what you want and you should create 2 queries:

    1 query to merge Accounts with RelationshipOptionSet and

    1 query to merge Accounts with CustomerHealthOptionSet.

     

    If you still want 1 query in which you merge Accounts with both tables, then the query should look like (if I didn't make any mistakes, obviously I can not test):

     

    let
        Source = OData.Feed("https://xxxxxxxxxx.api.crm4.dynamics.com/api/data/v8.2/"),
        accounts_table = Source{[Name="accounts",Signature="table"]}[Data],
        #"Removed Other Columns" = Table.SelectColumns(accounts_table,{"address1_country", "_new_subcategory_value", "address1_stateorprovince", "aaaa_customerhealthstatus", "_new_category_value", "customertypecode", "statuscode", "territorycode", "aaaa_account_aaaa_customerhealthscore", "aaaa_account_aaaa_customerhealth", "aaaa_account_aaaa_customerhealthscore_Customer", "aaaa_account_aaaa_customerhealthscore_MAT", "new_category", "new_subcategory"}),
        #"Filtered Rows" = Table.SelectRows(#"Removed Other Columns", each ([aaaa_customerhealthstatus] <> null)),
        #"Merged Relationship" = Table.NestedJoin(#"Filtered Rows",{"customertypecode"},RelationshipOptionSet,{"Value"},"NewColumn.1",JoinKind.LeftOuter),
        #"Merged Customer Health" = Table.NestedJoin(#"Merged Relationship",{"aaaa_customerhealthstatus"},CustomerHealthOptionSet,{"Value"},"NewColumn.2",JoinKind.LeftOuter),
        #"Expanded Relationship" = Table.ExpandTableColumn(#"Merged Customer Health", "NewColumn.1", {"Option"}, {"NewColumn.1.Option"}),
        #"Expanded Customer Health" = Table.ExpandTableColumn(#"Expanded Relationship", "NewColumn.2", {"Option"}, {"NewColumn.2.Option"}),
        #"Renamed Columns" = Table.RenameColumns(#"Expanded Customer Health",{
        {"NewColumn.1.Option","Relationship"},
        {"NewColumn.2.Option","Customer Health"}
        })
    in
        #"Renamed Columns"

     

    Notice that now every step proceeds with the previous step, e.g. step #"Merged Customer Health" now proceeds with #"Merged Relationship" instead of with #"Removed Other Columns" in your code. Etcetera.