dimension_group Automatic Label Suffix

PaulM1
New Member

Using a dimension_group of type time, Looker automatically appends “Date” to the label. For example, given the following dimension_group:

  dimension_group: DateTimeCanceled_ntz {
    label: "Date Canceled (UTC)"
    type: time
    convert_tz: no
    timeframes: [
      raw,
      date
    ]
    sql: ${TABLE}."DATETIME_CANCELED" ;;
  }

When navigating the Explore, the label for this dimension_group becomes “Date Canceled (UTC) Date”. I wish it to be the value I explicitly entered in the label parameter: “Date Canceled (UTC)”

Any chance we can override this automatic suffixing of the label:

1 9 2,722
9 REPLIES 9

If you only want to use date, then change it to dimension with type date. 🙂

Actually I wouldn’t mind this suffix to be optional. In so many cases it’s not needed

PaulM1
New Member

Sorry for the misrepresentation. I do have many date/time Dimension Groups that utilize more than just the date type. Either way, I think the point stands that the automatic suffixing of labels can sometimes create redundant information or confusion for the end users.

Looker sorts the view fields alphabetically. If the engineer wishes to organize their view fields, they must standardize their Dimension & Measure labeling carefully. And if one wishes all date/time fields to be grouped together, they might name them accordingly:

  • “Date/Time Created”
  • “Date/Time Started”
  • "Date/Time Ended
  • “Date/Time Closed”
  • “Date/Time Canceled”

That can be a strong organizational scheme for end users that need to easily locate the fields they wish to use in their dashboards. Especially when they are given Views with large field lists. But when they show up like this:

  • “Date/Time Created Date”
  • “Date/Time Started Date”
  • “Date/Time Ended Date”
  • “Date/Time Closed Date”
  • “Date/Time Canceled Date”

First of all, it’s redundant. Secondly, an argument can be made that it’s confusing since a time Dimension Group can contain more than just the raw date. Finally, Looker gives us the label Parameter for flexibility. Why wouldn’t we be given full control over the resulting label?

+1 for making this optional, or configurable. This always throws me off.

+1 can we turn this post into a feature request to be able to vote?

It’s tricky but We can actually control that with a combination of group_label, group_item_label and liquid!

Here is an example snippet:
[EDIT] Improved the code to make it timeframe agnostic (less pain to add new timeframes!

  dimension_group: created_utc {
    convert_tz: no
    description: "All those dimensions are in UTC"
    group_label: "Created Date (UTC)"
    label: "Created (UTC)"
    group_item_label: "{% assign timeframe = _field._name | remove: \"order_items.created_utc_\" | replace: \"_\" , \" \" | capitalize%}Created {{ timeframe }} (UTC)"
    type: time
    timeframes: [time, date, week, month, day_of_month, day_of_week, week_of_year]
    sql: ${TABLE}.created_at ;;
  }

Here is the output in the field picker:
image

Note that we cannot have that same syntax in the actual column name in the data table (that’s why I used the label parameter to still add the UTC part).

Hope that helps you folks!

I was struggling with this for a while but it turns out the solution is actually quite simple.

If you set the group_label, you’ll see that the dimension name is prefixed onto all the timeframes. You can then set the label to “” to remove these.

So in this case:

group_label: “Date Canceled (UTC)”

label: “”

Is there a way to remove the suffix in the label ? 

I want to do a german translation which is done using Cyril suggestion . 

When trying to apply the same type of logic to the label , i get the translation as in the field picker but with a suffix: 

dimension_group: datum {
group_label: "Zeit"
group_item_label: "{% assign timeframe = _field._name | remove: \"umsatzposition.datum_\"
| replace: \"_\" , \"\"
| replace: \"year\" , \"Jahr\"
| replace: \"month\" , \"Jahr-Monat\"
| replace: \"date\" , \"Datum\"
| replace: \"quarter\" , \"Quarter\"
| replace: \"week\" , \"Woche\"
%}{{ timeframe }}"
label: "{% assign timeframe = _field._name | remove: \"umsatzposition.datum\"
| replace: \"year\" , \"Jahr\"
| replace: \"month\" , \"Jahr-Monat\"
| replace: \"date\" , \"Datum\"
| replace: \"quarter\" , \"Quarter\"
| replace: \"week\" , \"Woche\"
%}{{ timeframe }}"
type: time
description: "date column"
timeframes: [
raw,
time,
date,
week,
month,
quarter,
year
]
convert_tz: no
sql: CAST(${TABLE}.datum as TIMESTAMP) ;;
}

so the field picker looks fine, 

eb535773-bcce-43e5-a476-98dbb4323a20.png

But in the visualization i have the following: 

306e1396-13e2-4844-898d-c4b49af6923d.png

so I get the translation as wanted but i also have the suffix which is appended . 

Is there a good way to get rid of that suffix ? 

I would like to get “Jahr” instead of “Jahr Year”, or “Jahr-Monat” instead of “Jahr-Monat Month”

anyone know if this is possible and if so how ? 

_field._name is not evaluating to any value, can someone help me, I want to change label of a dimension based on the value of other dimension 

Top Labels in this Space
Top Solution Authors