21

Reusable Custom Functions - No more copying!

Hi support,

I noticed that i reuse a lot of functions time and time again. Sometimes even in the same Klip. This means i have to copy a lot of the formula and only change the one column metric. AND if i have to make a change i have to edit all the existing formulas in all of the klips. Also, doing this there is a bigger chance that i make more mistakes.

I would suggest custom function where you could create one function and then add the one unique thing about it. (eg: A:A). The function ofcourse returns the result you would like.

In addition to this, it be also a idea to to add REF (eg: labels) that aren't visible in the Klip but contain special custom calculations. 

Thanks in advance for considering.

Rene

12 comments

  • Avatar
    Scott Lawrence Official comment

    Hi All,

    Thanks for your inputs here and sharing your use cases.  Will raise as an enhancement request and associate your names with it.

    Cheers,

    Scott.

  • 0
    Avatar
    Nathan Marks

    I agree, this would be immensely helpful

  • 1
    Avatar
    Randy Wijnants

    I agree! I find myself doing the copy-pasting multiple times, with large formula's. Coming from a developer background I like to think of some kind of template mechanism with optional variables to fill in. Think of a class > instances in programming.

    Thanks.

  • 0
    Avatar
    Matthias Moeser

    Dear klipfolio staff,

    my request tunes in with the previous posts:

    Currently I am heavily using dynamic data sources to extract data from pipedrive.

    Below you find a minimal example of the code I currently use in a klip:

        MAPFLAT(
            NUMBERFORMAT(
                ARRAY(
                    0
                    , CUMULATIVE(
                        REPEAT(500, 10)
                    )
                ) + 1
            )
            , "pipedriveDealsStart"
            , @/data/id;
        )

    My problem here is that the code allone becomes rather unwieldy. This is especially the case, when using functions such as GROUPBY() and SELECT().

    Both require the referenced data arrays to have the same length. The only way I know to meet this requirement, is to paste the same code block, altered only by the required data field. This is terrible for readability. 

    Is there a more elegant way to do this?

    Maybe you've already hidden a feature for custom functions with arguments or, simply variables, storing the entire result of the above code block somewhere.

    Cheers,

    Matthias

     

     

  • 0
    Avatar
    Leann Lewis

    I like the "class" concept.

    I also think it could be useful to have a collapsible favorites "Clipboard" that's always available from within the Klip editor (sort of how Prezi has for images but this would be code snips with nicknames and data source references removed).

  • 0
    Avatar
    Chad McGimpsey

    Where is this on your to-do list? This seems like a really basic feature, and it's been almost two years since this was brought up.

  • 1
    Avatar
    Meggan King

    Hi Chad,

    We have introduced Modeled data sources which allow you to do some of your formulas at the data source level, instead of at the Klip level. Have you looked at this yet? It may help with your situation. There are more features in the Modeled view which are coming soon - such as joining multiple data sources (will replace LOOKUP in Klip Editor for many situations), allow you to do most of your XPATH work in the Model, instead of repeating in every Klip, etc. 

    This won't resolve things in all situations though, so if you want to chat more, you can always reach out with some examples to support@klipfolio.com

    https://support.klipfolio.com/hc/en-us/articles/360002354954-BETA-Introduction-to-modelled-data-sources

     

    Thanks!

    Meggan

  • 0
    Avatar
    Tanmay Kumar

    Hi! Meggan,

     

    Looking forward to using multiple data sources in Modeled view at the earliest.  Any time-frame for this?

     

    Regards,

    Tanmay

  • 0
    Avatar
    Chad McGimpsey

    Hey Meggan,

    Thanks. I have seen Modeled data sources. One piece of feedback I have is that it would be nice to be able to create a data source as a modeled data source (i.e. have one data source instead of the original data source and the modeled data source). That way we could easily keep column headers for data without duplicating data sources (or just allow data sources to have custom column headers coming from the data... this would get rid of a ton of SLICE() calls). I'd also really look forward to having multiple data sources in one Modeled data source... that will definitely help.

    For the original question, my use case is that I have graphs on a number of Klips that show data for the past 13 months. I created a formula that outputs 13 timestamp values as an array, which I use to set the X-axis. Then in my graph's series data I use a lookup function to match each month with the corresponding data field (some months may have no data, and so they are missing from the data source). So I'd love to have a function called LAST_13_MONTHS() which I could use across my Klips. Another way to do it would be a Modeled data source, but I couldn't find a way to create a Modeled data source using Klipfolio functions. I guess since most of this data is coming from our database, I could just run this as a separate SQL query (i.e. the query just returns unix timestamps for the last 13 months). This feels like a workaround though; I'd much rather be able to use a custom function, variable, or "in-house" data source across my Klips.

  • 0
    Avatar
    Meggan King

    Hey -

    Multiple data sources in a model are coming soon! We've been busy testing them and it's been going well. 

     

    Chad - I wonder if having a look at what you are doing would help me better understand your use case. There are ways you can accomplish this using our date filters, so you may be able to simplify things. You can filter on dates in the past months using conditions on date filters. If you'd like, you can open a ticket at support@klipfolio.com and we can help out. 

     

    Thanks

    Meggan

  • 0
    Avatar
    Chad McGimpsey

    Hey Meggan,

    That's ok. I have a working solution for now. I came up with the Date range in the x-axis scheme by reading this: https://support.klipfolio.com/hc/en-us/community/posts/360017863234-Line-chart-time-series-with-missing-dates.

  • 0
    Avatar
    Kary Rogers

    I would LOVE a way to make a custom, reusable function or variable based on some formula that may use multiple data sources. I've gotten good use from merging modeled data sources but that won't do what I need for some things.

Please sign in to leave a comment.