Forum Discussion

primolee's avatar
primolee
Icon for Helper V rankHelper V
6 years ago
Solved

Make a list of function names into a record with Function values

Hello everyone, Currently I am making a record of my functions manually. [ A = A, B = B, C = C, ] However, I will keep on making more functions so I was wondering if there is a way to creat...
  • Jimmy801's avatar
    Jimmy801
    6 years ago

    Hello primolee ,

     

    are these data sources (xlsx) so different that your are not able to create one function to combine them?

    However... this example should help you to create a record based on a Table/List. In my example i have a table with column function name and function.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8ivNTUot0nMrys9V0kHhxepEK4WkVpTA5BDs2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Function name" = _t, Function = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Function name", type text}, {"Function", type text}}),
        ChangeToFunction = Table.TransformColumns(#"Changed Type", {"Function", each Expression.Evaluate(_, #shared)}),
        CreateRecord= List.Last(List.Generate
        (
            ()=>
            [
                FinalRecord = [],
                Counter = 0
            ],
            each [Counter]<= Table.RowCount(ChangeToFunction),
            (x)=>
            [
                FinalRecord = Record.AddField(x[FinalRecord], ChangeToFunction[Function name]{x[Counter]}, ChangeToFunction[Function]{x[Counter]}),
                Counter = x[Counter]+1
            ],
            each [FinalRecord]
        ))
    in
        CreateRecord

     

    If this post helps or solves your problem, please mark it as solution.
    Kudos are nice to - thanks
    Have fun

    Jimmy