Getting Started with Case Statements In Domo

Damien Smith - Tuesday, January, 09, 2018

My previous article ‘Introduction to Beast Mode in Domo’ provides a high level view of Beast Modes and why you would use them. The examples were basic calculations of profit and margin for the whole dataset.

Things get a little more complicated where we need to return results from only some of the data. Case Statements are used for this purpose.

Case Statement Structure

I don’t have a background in databases or SQL so when I first started using Domo I was struggling with case statements – it just wasn’t clicking for me.

It all came together when I thought of the case statement as a filter on the data and then doing something with the resulting rows.

The case statement has the following structure:

CASE WHEN <some filter conditions> THEN <do something> END

Example

We need a pie chart to always show the split of shipping mode from last year without updating date filters each year.

This beast mode says that when the year of the order date equals the year of the current date – 1 (ie. filter on last year), then return the data in the Ship Mode column:

The beast mode becomes the name of a new virtual column which only shows results for where the order date was 1 year ago (2017 at the time of writing).

Using the above beast mode, this pie chart shows the shipping mode composition for last year

The end result:

Comment

Your email address will not be published. Required fields are marked *

Search