Forum Discussion

S3's avatar
S3
Helper III
3 years ago
Solved

A More Dynamic Refresh?

Hello everyone,  I have a question regarding the refresh I make every 3 days to the same table. The issue is that the columns are based on the activity which happened and it makes problems with th...
  • BA_Pete's avatar
    BA_Pete
    3 years ago

    Hi S3 ,

     

    *EDIT* Corrected mistyped function in code window:

    Table.TransformColumnTypes > Table.TransformColumns.

     

    You're getting this error with my code as you're trying to apply data types (Int64.Type) to each column instead of applying a function (Number.From, Text.From etc.).

    Your new changed types step should actually look more like this:

     

    #"Changed Type" =
    Table.TransformColumns(
        #"Promoted Headers",
        {
            {"Visits", Number.From},
            {"Conversions", Number.From},
            {"Visits with Conversions", Number.From},
            {"goal_1_nb_conversions", Number.From},
            {"goal_1_nb_visits_converted", Number.From},
            ...
            ...
        },
        null,
        MissingField.Ignore
    )

     

     

    Pete

  • BA_Pete's avatar
    BA_Pete
    3 years ago

    Hi S3 ,

     

    Apologies for the delay. A hero has answered the call:

    Try this, credit to MarkLaf :

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("FcqxDQAxCATBXi62BJwNNrUg+m/j+WQ1wVaBFKNQqVgw7uMxmN6X6FVQE3WxjH/Id8PPYLpp6P4A", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Activity 1" = _t, #"Activity 2" = _t, #"Activity 3" = _t]),
        transformTypes =
        Table.TransformColumns(
            Source,
            {
                {"Activity 1", each Date.From(_, "en-GB"), type date},
                {"Activity 2", each Number.From(_, "en-GB"), type number},
                {"Activity 3", each Number.From(_, "en-GB"), type number}
            },
            null,
            MissingField.Ignore
        )
    in
        transformTypes

     

    Pete