Forum Discussion

spr_RK's avatar
spr_RK
Frequent Visitor
4 years ago
Solved

List.Accumulate conditional replace value in dynamic columns from lookup table

Hello all - I have 3 tasks I have been able to accomplish on a small sample set of data, but with my full dataset the refresh never finishes due to what I am assuming is a performance issue on the la...
  • wdx223_Daniel's avatar
    4 years ago

     

    let
        Sales = Excel.CurrentWorkbook(){[Name="Sales"]}[Content],
        SpecificLists = Table.Buffer(Table.Group(Excel.CurrentWorkbook(){[Name="SpecificLists"]}[Content],"Code",{"n",each _})),
        Columns = Table.Buffer(Excel.CurrentWorkbook(){[Name="Columns"]}[Content]),
        DashboardAssignments = Table.Buffer(Excel.CurrentWorkbook(){[Name="DashboardAssignments"]}[Content]),
        Custom1 = Table.FromRecords(
                                    Table.TransformRows(
                                                        Sales,
                                                        each let a=SpecificLists{[Code=[Code]]}?[n]?,
                                                                 b=Record.ToTable(_)
                                                             in Record.FromTable(
                                                                                 Table.ReplaceValue(
                                                                                                    b,
                                                                                                    each [Name],
                                                                                                    each List.Contains(Columns[Dashboard],[Name]),
                                                                                                    (x,y,z)=>if z
                                                                                                             then DashboardAssignments{[Account_Dashboard=(a{[Dashboard=y]}?[Updated Name]? ??x)&"|"&y]}?[Name]?
                                                                                                             else x,
                                                                                                    {"Value"}
                                                                                                   )
                                                                                )
                                                       )
                                   )
    in
        Custom1