Filter with YouPrep™

Overview

When you are building your story, you might want to filter your data to display only a part of them. Previously, you did it two ways: the query in mongo and with postprocess. Thanks to all the latest releases, you are able to filter your data without any pain thanks to the YouPrep™. You can apply the following operations to your dataset:

  • Delete columns
  • Keep columns
  • Filter Rows
  • Top N rows
  • Argmax
  • Argmin
leaderboard evolution

Examples

Warning

Before you start!

I’m working on a datasource containing the GDP and population for all countries between 2012 and 2016. I want to display only the evolution of the GDP for the US and UK between 2012 and 2016. To obtain my filtered dataset, I’m going to realize different step in YouPrep™.

leaderboard evolution
Ex1: Keep columns

Go in the Query and click on “filter”. To keep only the column “Time”, “Country Name” and “GDP” you can use the delete columns or keep columns operation.

📝 Keep only the columns you need to make it crystal clear.
barchart groups

barchart groups

Your YouPrep step should look like this:

keep column

keep column

Ex2: Filter columns

Then you need to apply the Filter Rows operation. You need to select the column, the operation and the value on which you want to apply your operation. In my example, I want to keep all the rows where the country name is “United States” OR “United Kingdom”

📝 Do not hesitate to add all your filtering operations into one step.

Your YouPrep step should look like this:

filter operation step

filter operation step

NB: You have different ways to perform this filtering operation:

👉 Using the “Is one of” filtering operation: You just need to write the name on which you want to apply your filtering operation and then press the enter button. You can add as much wording as you want.

is one of

is one of

👉 Or, using a “regex” operation:

Important

A regular expression is a sequence of characters that define a search pattern.

The syntax of the Regex expression in Toucan allow you to apply all the regex operations (matches a single character, except characters, characters in a range, any digit, any non-digit…) In my example i want to keep United States and United Kingdom (and not United Arab Emirates) so I need to add a regex expression. United [KS] will allow me to keep all the rows containing United and matching a single character in the list KS (case sentitive).

Note

You could test your regex syntax here 👉 Go in the RegEx reference menu for all the regex syntax Or here 👉 Find all the regex syntax in the bottom right-hand corner into the Quick references block

matches pattern

matches pattern

Ex3: Top N rows

You can also apply different operations to your dataset: Top N rows will allow you to keep a TOP N of the rows ordering them with the column of your choice. Below you can find a TOP N rows operations with a group by Country Name (if you need to aggregate your data before ordering it and keeping the top values):

📝 Top N rows could be really helpful to display a fix number of rows. It’s the perfect step to use for tile

Your YouPrep step should look like this : filter operation YouPrep

You’re all set, your dataset is looking like this: filter operation dataset

Ex4: Argmin/Argmax

Argmin/Argmax: This operation will display you the smallest or the biggest value of your column (you can also make the choice to group by another column).

📝 The perfect tool for your HKPI!!!

Do not hesitate to read the weaverbird documentation if you need any further informations on the YouPrep!