Lazy Beast Mode Field Injection (aka inject by Reference)

When creating a beast mode field, it is possible to compose beast mode fields by injecting an existing beast mode field into the formula. This is a great, convenient feature, and it is currently implemented by eagerly grabbing the formula for the referenced beast mode field and copying it into the formula being written.

 

However, this can introduce long-term maintenance issues if I later want to augment the definition of a nested beast mode formula.

 

For example, let's say I want to create a card showing the sum of all order revenue by customers in our preferred member program as a percentage of total order revenue. I define the following beast mode calculations:

 

Conceptually:

revenue_order = CASE WHEN status NOT IN ('Cancelled', 'Abandoned') THEN 1 ELSE 0 END

preferred_revenue = CASE WHEN revenue_order = 1 AND preferred = 1 THEN revenue ELSE 0 END

all_revenue = CASE WHEN revenue_order = 1 THEN revenue ELSE 0 END

preferred_percentage = SUM(preferred_revenue) / SUM(all_revenue)

 

Implemented

revenue_order = CASE WHEN status NOT IN ('Cancelled', 'Abandoned') THEN 1 ELSE 0 END

preferred_revenue = CASE WHEN

                      CASE WHEN status NOT IN ('Cancelled', 'Abandoned') THEN 1 ELSE 0 END = 1 AND preferred = 1                     THEN revenue ELSE 0 END

(and so on for copying in the composed fields)

 

 

Preferred_percentage now lets me analyze the desired target over arbitrary date buckets in cards. Great.

 

However, what happens if we add another order status that excludes an order from revenue calculations?

 

Because the revenue_order field was eagerly copied into the preferred_revenue, all_revenue, and preferred_percentage calculations, I have to go track down all of the beast mode formulas that copied in the revenue_order flag and copy the new definition into them.

 

Composing beast mode fields would be significantly more powerful and efficient to use if it was possible to inject a reference to another beast mode field that was resolved at query time. This would allow users to abstract away common concepts and reuse them in all of their cards without worrying about changing the underlying definition of the concepts in the future. I believe it would be quite a boon to Domo's prospective value to clients if this were possible.

37
37 votes

· Last Updated

Comments

This discussion has been closed.