Question

Dynamic Measures

  • 1 June 2018
  • 2 replies
  • 375 views

Hi There,


My database has two tables

(1) Item Table - Lookup table of all Items i.e jeans, shirts, T-Shirts , etc.

it has fields as



  • ID - integer - primary key

  • Name - string

    (2) Sales Table - contains sales data for each item.

    it has fields as

  • ID - integer - Primary Key

  • ItemID - integer - foreign key to Item.ID

    *SalesAmt - numeric

  • year - numeric

  • Month - numeric


I have created dimension as “Item Name” and measure as “Sales Amt”


How do I

(1) dynamically show measures in Explore as “Jeans Sales Amt” , “Tshirt Sales Amt” ?

(2) Allow my user to calculate between these values. such as

Sales Amt of Item Jeans

Plus

Sales Amt of Item Tshirt


2 replies

Userlevel 2

Hi @JATIN,


This sounds like a great use case for table calculations and custom fields. It sounds like you are interested in users creating dynamic, on-the-fly metrics. We can create on-the-fly filtered measures (i.e. sales amount filtered by Jeans, or Tshirts) using the custom fields feature available in the explore interface.


As for dynamically changing the label of Sales Amount measures, we can accomplish this using liquid in the label parameter of our lookml measure. The liquid variables that are supported in the label parameter can be found here (these will have the La tag next to them). The liquid variables you would use here would be dependent on the conditional logic of the measure name.


Another option for making your measure dynamic is by using liquid templated filters, which will allows users to select the dimension they wish to filter the measure by on the front end, via a filter. This approach is outlined here.


Please visit us at help.looker.com if you would like to explore these options further!

Thank you Quinn,

This is exactly what I was looking for.

I have enabled the Customer Fields and now I am doing further testing. I will let you know if I need further help.

Reply