{"id":622,"date":"2019-03-03T11:00:55","date_gmt":"2019-03-03T11:00:55","guid":{"rendered":"https:\/\/i-spark.nl\/uncategorized\/de-klipfolio-lookup-functie\/"},"modified":"2026-01-02T12:51:42","modified_gmt":"2026-01-02T12:51:42","slug":"the-klipfolio-lookup-function","status":"publish","type":"post","link":"https:\/\/i-spark.nl\/en\/blog\/the-klipfolio-lookup-function\/","title":{"rendered":"The Klipfolio LOOKUP function"},"content":{"rendered":"<p>Would you like to know more about Klipfolio? Read our blog on our <strong>top 5 common design flaws that we encounter in Klipfolio <a href=\"https:\/\/i-spark.nl\/en\/blog\/top-5-common-design-flaws-for-klipfolio-dashboards\/\">here<\/a>!<\/strong><\/p>\n<h2><strong>The LOOKUP function<\/strong><\/h2>\n<p><span style=\"font-weight: 400;\">One of our most frequently used functions in <a href=\"https:\/\/i-spark.nl\/en\/products\/modular-products\/klipfolio-dashboard-klips\/\">Klipfolio<\/a> is the LOOKUP function. Unfortunately, this is not one of the easiest functions. A lot of our clients come to us with questions regarding this function, when it does not quite work as expected. Especially in the beginning I had to get used to it as well.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">I would like to explain the structure of the LOOKUP function. But, before I do this, I have to explain a few different concepts: GROUP, GROUPBY, SELECT &amp; IF. Especially the difference between IF and SELECT is interesting.\u00a0<\/span><\/p>\n<h3><b>GROUP<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">The grouping function sees to it that you can take a series of values and make unique values out of this.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">So, in column A:A you have the values apple, apple, banana, lemon, lemon, lemon, pear, pear, and you want to know the unique values. In this case you can use GROUP(A:A), or, sometimes GROUP(SLICE(A:A)) if your column has a header. <\/span><\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-medium wp-image-254\" src=\"https:\/\/i-spark.nl\/wp-content\/uploads\/2020\/03\/Schermafbeelding-2020-03-03-om-11.58.09-300x195.png\" alt=\"\" width=\"300\" height=\"195\" srcset=\"https:\/\/i-spark.nl\/wp-content\/uploads\/2020\/03\/Schermafbeelding-2020-03-03-om-11.58.09-300x195.png 300w, https:\/\/i-spark.nl\/wp-content\/uploads\/2020\/03\/Schermafbeelding-2020-03-03-om-11.58.09.png 767w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<h3><b>GROUPBY<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Imagine, you want to calculate a specific value (measure) per group (dimension). Then, you can use GROUPBY. If the values belonging to fruit, 1, 2, 3, 4, 5, 6, 7, 8, are shown in column B:B and we want to sum those, we can use GROUPBY. This function takes the format of GROUPBY(dimension, measure, aggregation function). However, if you leave the last statement blank, GROUPBY will automatically take the sum.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">So, GROUPBY(A:A,B:B) returns the values 3 (1+2), 3 (3), 15 (4+5+6), and 15 (7+8). The values return automatically in the order of which GROUP has been sorted, which is alphabetically.<\/span><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-medium wp-image-255\" src=\"https:\/\/i-spark.nl\/wp-content\/uploads\/2020\/03\/Schermafbeelding-2020-03-03-om-11.58.19-300x169.png\" alt=\"\" width=\"300\" height=\"169\" srcset=\"https:\/\/i-spark.nl\/wp-content\/uploads\/2020\/03\/Schermafbeelding-2020-03-03-om-11.58.19-300x169.png 300w, https:\/\/i-spark.nl\/wp-content\/uploads\/2020\/03\/Schermafbeelding-2020-03-03-om-11.58.19.png 769w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<h3><b>SELECT<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">A SELECT function is used when you only want to measure specific values. Suppose that in our previous example we only want the lemons. In this case what we really want to code is: select the values from column B with the requirement that column A has a specific value. Or: SELECT(B:B, A:A = \u201cLemon\u201d).<\/span><\/p>\n<p><span style=\"font-weight: 400;\">A SELECT statement will throw away records. We started with 8, but after using SELECT we will be left with only 3. You can also see this when you evaluate the formula with the lightning bolt: if you hover over column B:B you are shown 8 values. Likewise, if you are selecting the part \u2018A:A = \u201clemon\u201d\u2019 you are shown 8 values (true or false). But, if you select the entire formula, you are shown only 3 values. These are 4, 5, and 6.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">It is important to realize that both columns of the select formula should have the same amount of records. If this is not the case, the results of the formula can be unexpected. Problems often arise at for example empty cells or NULL values, especially at the bottom of a data source.<\/span><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-medium wp-image-256\" src=\"https:\/\/i-spark.nl\/wp-content\/uploads\/2020\/03\/Schermafbeelding-2020-03-03-om-11.58.30-300x151.png\" alt=\"\" width=\"300\" height=\"151\" srcset=\"https:\/\/i-spark.nl\/wp-content\/uploads\/2020\/03\/Schermafbeelding-2020-03-03-om-11.58.30-300x151.png 300w, https:\/\/i-spark.nl\/wp-content\/uploads\/2020\/03\/Schermafbeelding-2020-03-03-om-11.58.30-768x387.png 768w, https:\/\/i-spark.nl\/wp-content\/uploads\/2020\/03\/Schermafbeelding-2020-03-03-om-11.58.30.png 770w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<h3><b>IF<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">When using the IF function, you can test whether a specific value satisfies certain criteria. Does this hold, then you will do \u201cX\u201d. Does this not hold, then you will do \u201cY\u201d. In practice \u201cX\u201d or \u201cY\u201d is usually the number 0. In other words: IF(the value in column A:A = \u201clemon\u201d, B:B, 0). That is: If in column A there is a value \u201clemon\u201d, take the value from column \u201cB\u201d, or else take value 0. The result is 0, 0, 0, 4, 5, 6, 0, 0.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">It is important to realize that the 3 parts of the formula need to have the same amount of records. *) Likewise, the end result needs to have the same amount of results. Is this not the case, then yet again the formula can have unexpected outcomes.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-257\" src=\"https:\/\/i-spark.nl\/wp-content\/uploads\/2020\/03\/Schermafbeelding-2020-03-03-om-11.58.37-300x154.png\" alt=\"\" width=\"300\" height=\"154\" srcset=\"https:\/\/i-spark.nl\/wp-content\/uploads\/2020\/03\/Schermafbeelding-2020-03-03-om-11.58.37-300x154.png 300w, https:\/\/i-spark.nl\/wp-content\/uploads\/2020\/03\/Schermafbeelding-2020-03-03-om-11.58.37.png 760w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<h3><b>LOOKUP<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">A LOOKUP function has 3 components: LOOKUP(specific items, where to search, return value).<\/span><\/p>\n<p><span style=\"font-weight: 400;\">If we dissect this:<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">In the first argument are the values that we are searching for. This can be for example months, such as \u201c\u201c2018-07\u201d, \u201c2018-08\u201d, \u201c2018-09\u201d, 2018-10\u201d etc. In this example, let us assume that we want to show those 4 months, and not the other months. In practice these are often de values of the X-axis in a graph.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In the second argument we have the entire batch of values, in which the values from the first argument can be located. This is allowed to be in a different format. However, then we have to change these in a formula.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">It can be the case that there are many more months in the source data. These values will not return in the formula. That is what you want, because in the first argument, you declared what you want to look up.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">It could also be the case that there aren\u2019t that many values in the source data. For example, you have the values of July and August 2018, but (not yet) those of September and October. However, you do want to show those in your graph. In this case, the first component of the lookup function will not return in the second component. Here, the lookup formula will return an empty cell.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In the third argument, you explain what exactly you are going to calculate. So, for example, we have looked up those 4 months in a batch of data (1st component), we found those months (2end component), in for example column A:A), and now we want to return the value that exists in a different column, for example B:B.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The amount of values from argument 1 is in most cases, different from the number of values in argument 2. But, the amount of values in component 2 should be equal to the number of values in argument 3. If this is not the case, something is going wrong.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In this example I assume that we have a graph, with on the X-axis and on the Y-axis the number of sessions to a particular website. The X-axis is labelled \u2018Months\u2019.<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">There are a few possibilities:<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">1. The data source in which we search always has 1 value per month. For example: total number of sessions per month.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In column A:A we have months, in column B:B we have the number of sessions in that month.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The formula becomes:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-258 alignnone\" src=\"https:\/\/i-spark.nl\/wp-content\/uploads\/2020\/03\/Schermafbeelding-2020-03-03-om-11.58.47-300x171.png\" alt=\"\" width=\"300\" height=\"171\" srcset=\"https:\/\/i-spark.nl\/wp-content\/uploads\/2020\/03\/Schermafbeelding-2020-03-03-om-11.58.47-300x171.png 300w, https:\/\/i-spark.nl\/wp-content\/uploads\/2020\/03\/Schermafbeelding-2020-03-03-om-11.58.47-768x438.png 768w, https:\/\/i-spark.nl\/wp-content\/uploads\/2020\/03\/Schermafbeelding-2020-03-03-om-11.58.47.png 791w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">LOOKUP(&amp;maanden, A:A, B:B)<br \/>\nmaanden = months<\/span><\/span><\/p>\n<p><span style=\"font-weight: 400;\">2. <\/span><span style=\"font-weight: 400;\">The data source in which we search always has multiple values per month. For example: the number of sessions per day.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In column C:C we have a date, in column D:D the amount of sessions per day.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The formula becomes:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">LOOKUP(&amp;maanden,<br \/>\nGROUP(date_convert(C:C,\u201dyyyyMMdd\u201d,\u201dyyyy-MM)),GROUPBY(date_convert(C:C,\u201dyyyyMMdd\u201d,\u201dyyyy-MM),D:D)<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In other words: at the second argument a GROUP and at the third component a GROUPBY which on its own term has 2 components.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The first component is the exact same as the part in the GROUP of the second component. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">3. <\/span><span style=\"font-weight: 400;\">The data source in which we are searching has another dimension besides months.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">For example: Total amount of sessions per month per channel.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The months, channels, and specific numbers are reported in column C:C, D:D, and, E:E, respectively.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The formula for the channel \u201corganic\u201d becomes:<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">LOOKUP(&amp;maanden, select(C:C, D:D = \u201corganic\u201d), select(E:E, D:D = \u201corganic\u201d))<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">Or<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">LOOKUP(&amp;maanden, GROUP(C:C),GROUPBY(C:C,IF(D:D = \u201corganic\u201d,E:E,0))<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><\/p>\n<p><span style=\"font-weight: 400;\">At the SELECT formula we only select records that we want.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">At the IF formula we actually select everything, but only if the criteria are satisfied than the values are returned.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">4.<\/span><span style=\"font-weight: 400;\">In the data source we have another dimension besides months and the source is in days, not months.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In column C:C the days are represented, in column D:D the channels, and in column E:E the amounts.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The formula for the channel \u201corganic\u201d then becomes:<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">LOOKUP(&amp;maanden, GROUP(SELECT(DATE_CONVERT(C:C,\u201dyyyyMMdd\u201d,\u201dyyyy-mm\u201d),D:D = \u201corganic\u201d),GROUPBY(SELECT(DATE_CONVERT(C:C,\u201dyyyyMMdd\u201d,\u201dyyyy-mm\u201d),D:D = \u201corganic\u201d,select(E:E, D:D = \u201corganic\u201d))))<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">Or<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">LOOKUP(&amp;maanden, GROUP(date_convert(C:C,\u201dyyyyMMdd\u201d,\u201dyyyy-MM)), GROUPBY(date_convert(C:C,\u201dyyyyMMdd\u201d,\u201dyyyy-MM),IF(D:D = \u201corganic\u201d,E:E,0))<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In the select formula, we only select the records that we want. Component 2, as well as both parts of component 3 get the SELECT function.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">For the IF function, we select all records, but actually, only in the last part do we say that we only want to use the values that satisfy the criteria. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">So, when do you use IF and when SELECT? Every situation is unique, so the silly answer is \u2018it depends\u2019. We do have a few precepts:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">If you use the same SELECT statement 3 times in a formula, the chance of getting an error increases. This is something I try to avoid. This could be by using the function IF, or by solving with a variable.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">The IF formula is more easily duplicated for other lines in your graph, as you only have to change 1 component.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">The IF formula is something I find to be clearer and easier to debug.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Sadly, using the IF formula is not always possible. It is working with SUM, but not with different aggregations like MIN.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Are you using the LOOKUP function, but are you running into problems? Feel free to <a href=\"https:\/\/i-spark.nl\/en\/contact-us\/\">contact<\/a> us. We can always have a look at it with you without any commitments!<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Would you like to know more about Klipfolio? Read our blog on our top 5 common design flaws that we encounter in Klipfolio here! The LOOKUP function One of our most frequently used functions in Klipfolio is the LOOKUP function. Unfortunately, this is not one of the easiest functions. A lot of our clients come [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":624,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[8],"tags":[184],"class_list":["post-622","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-klipfolio-2"],"acf":[],"_links":{"self":[{"href":"https:\/\/i-spark.nl\/en\/wp-json\/wp\/v2\/posts\/622","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/i-spark.nl\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/i-spark.nl\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/i-spark.nl\/en\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/i-spark.nl\/en\/wp-json\/wp\/v2\/comments?post=622"}],"version-history":[{"count":12,"href":"https:\/\/i-spark.nl\/en\/wp-json\/wp\/v2\/posts\/622\/revisions"}],"predecessor-version":[{"id":10256,"href":"https:\/\/i-spark.nl\/en\/wp-json\/wp\/v2\/posts\/622\/revisions\/10256"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/i-spark.nl\/en\/wp-json\/wp\/v2\/media\/624"}],"wp:attachment":[{"href":"https:\/\/i-spark.nl\/en\/wp-json\/wp\/v2\/media?parent=622"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/i-spark.nl\/en\/wp-json\/wp\/v2\/categories?post=622"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/i-spark.nl\/en\/wp-json\/wp\/v2\/tags?post=622"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}