Usage
view: retail_custom_calendar {
calendar_definition: {
reference_date: ref_date
timeframe_mapping: {
custom_date: custom_date
custom_period: custom_period
custom_quarter: custom_quarter
custom_season: custom_season
custom_week: custom_week
custom_year: custom_year
}
timeframe_ordinal_mapping: {
custom_date: custom_date
custom_period: custom_period
custom_quarter: custom_quarter
custom_season: custom_season
custom_week: custom_week
custom_year: custom_year
}
previous_ordinal_mapping: {
custom_date: custom_date
custom_week: custom_week
}
}
|
היררכיה
calendar_definition |
הגדרה
במסגרת השימוש בלוחות שנה בהתאמה אישית ב-Looker, הפרמטר calendar_definition מאפשר למפות את מסגרות הזמן של לוח שנה בהתאמה אישית ב-Looker לעמודות של טבלת לוח שנה בהתאמה אישית שיצרתם במסד הנתונים.
במאמר שימוש ביומנים מותאמים אישית ב-Looker מוסבר איך להגדיר קובץ תצוגה של יומן מותאם אישית.
בקובץ התצוגה של היומן המותאם אישית, מוסיפים את בלוק הפרמטרים calendar_definition. לדוגמה:
calendar_definition: {
reference_date: ref_date
timeframe_mapping: {
custom_date: custom_date
custom_period: custom_period
custom_quarter: custom_quarter
custom_season: custom_season
custom_week: custom_week
custom_year: custom_year
}
timeframe_ordinal_mapping: {
custom_date: ordinal_custom_date
custom_period: ordinal_custom_period
custom_quarter: ordinal_custom_quarter
custom_season: ordinal_custom_season
custom_week: ordinal_custom_week
custom_year: ordinal_custom_year
}
previous_ordinal_mapping: {
custom_date: prev_day_num
custom_week: prev_week_num
}
}
חשוב לדעת על בלוק הפרמטרים calendar_definition:
- חובה להשתמש בפרמטר
reference_date. - הפרמטרים
timeframe_mappingו-timeframe_ordinal_mappingוכל הפרמטרים המשניים שלהם הם פרמטרים נדרשים. מידע נוסף זמין במאמר בנושא מסגרות זמן חובה. - בלוק הפרמטרים
previous_ordinal_mappingנדרש רק אם רוצים להשתמש בלוח השנה המותאם אישית עם מדדים של השוואה לתקופה קודמת.
אפשר לעיין בקטע דוגמה בדף הזה.
אחרי שמבצעים מודלינג של טבלת היומן בהתאמה אישית ב-LookML, אפשר ליצור קבוצת מאפיינים של type: custom_calendar שמבוססת על תצוגת היומן בהתאמה אישית. אחרי זה משתמשי הקצה יכולים ליצור שאילתות בניתוח נתונים באמצעות מסגרות הזמן של מאפיין היומן המותאם אישית.
reference_date
הפרמטר reference_date מציין מאפיין בתצוגת היומן המותאמת אישית, שממופה לעמודה בטבלת מסד הנתונים של היומן המותאם אישית, שמספקת תאריך סטנדרטי ביומן, כמו 2026-01-01.
חשוב לזכור את הנקודות הבאות לגבי הפרמטר reference_date:
- הסימן
reference_dateנדרש, כי Looker משתמש בו כדי לחשב הצטרפויות מטבלאות הנתונים לטבלת היומן בהתאמה אישית, כדי לספק תוצאות של שאילתות שמשתמשות בטווח הזמן בהתאמה אישית. - הערך של
reference_dateחייב להיות ייחודי או מפתח ראשי.
בקטע דוגמה בדף הזה מוסבר איך reference_date מצביע על מאפיין שמדמה עמודה בטבלת היומן המותאם אישית.
timeframe_mapping
בלוק timeframe_mapping ממפה כל מסגרת זמן מותאמת אישית ב-Looker למאפיין שמייצג את העמודה המקבילה בטבלת מסד הנתונים של היומן המותאם אישית.
timeframe_mapping: {
custom_date: field-ref
custom_period: field-ref
custom_quarter: field-ref
custom_season: field-ref
custom_week: field-ref
custom_year: field-ref
}
בקטע דוגמה בדף הזה מוסבר איך כל תת-פרמטר timeframe_mapping מציין מאפיין שמייצג עמודה בטבלת היומן בהתאמה אישית.
timeframe_ordinal_mapping
בלוק timeframe_ordinal_mapping ממפה כל מסגרת זמן מותאמת אישית ב-Looker למאפיין שמדמה את העמודה המתאימה של מספר סידורי בטבלת מסד הנתונים של היומן המותאם אישית.
timeframe_ordinal_mapping: {
custom_date: field-ref
custom_period: field-ref
custom_quarter: field-ref
custom_season: field-ref
custom_week: field-ref
custom_year: field-ref
}
בקטע דוגמה בדף הזה מוסבר איך כל תת-פרמטר timeframe_ordinal_mapping מציין מאפיין שמייצג עמודה בטבלת היומן בהתאמה אישית.
previous_ordinal_mapping
אם רוצים ליצור מדדים של תקופה לעומת תקופה (PoP) שמשתמשים בלוח השנה המותאם אישית, צריך להוסיף גם בלוק previous_ordinal_mapping ל-calendar_definition.
בלוק previous_ordinal_mapping ממפה כל מסגרת זמן מותאמת אישית ב-Looker למאפיין שמייצג את העמודה המתאימה בטבלת מסד הנתונים של היומן המותאם אישית.
previous_ordinal_mapping: {
custom_date: field-ref
custom_week: field-ref
}
בקטע דוגמה בדף הזה מוסבר איך כל תת-פרמטר previous_ordinal_mapping מציין מאפיין שמייצג עמודה בטבלת היומן בהתאמה אישית.
מסגרות זמן חובה
חובה לציין את פרמטרי המשנה של מסגרות הזמן timeframe_mapping ו-timeframe_ordinal_mapping. אם מסגרת זמן ספציפית, כמו custom_season, לא רלוונטית ליומן המותאם אישית, עדיין צריך לכלול אותה על ידי הגדרת מאפיין placeholder בתצוגת היומן. לדוגמה:
dimension: season {
type: string
sql: 'N/A' ;;
hidden: yes
}
dimension: season_num {
type: number
sql: 0 ;;
hidden: yes
}
דוגמה
זו דוגמה לקובץ תצוגה בשם fiscal_calendar.view.lkml שמדמה טבלת לוח שנה מותאמת אישית בשם fiscal_calendar_table:
view: fiscal_calendar {
sql_table_name: fiscal_calendar_table ;;
calendar_definition: {
reference_date: reference_date
timeframe_mapping: {
custom_year: fiscal_year
custom_quarter: fiscal_quarter_of_year
custom_date: fiscal_date_of_month
custom_week: fiscal_week_of_year
custom_period: fiscal_period_of_year
custom_season: season
}
timeframe_ordinal_mapping: {
custom_year: fiscal_year_num
custom_quarter: fiscal_quarter_of_year_num
custom_date: fiscal_date_of_month_num
custom_week: fiscal_week_of_year_num
custom_period: fiscal_period_of_year_num
custom_season: season_num
}
previous_ordinal_mapping: {
custom_date: prev_custom_date
custom_week: prev_custom_week
}
}
dimension: reference_date {
type: date
primary_key: yes
sql: ${TABLE}.reference_date ;; # Name of the column in your database table that shows the standard date, such as `2026-01-01`
}
dimension: fiscal_year {
type: string
sql: ${TABLE}.fiscal_year ;;
}
dimension: fiscal_year_num {
type: number
sql: ${TABLE}.fiscal_year_num ;;
}
dimension: prev_custom_week {
type: number
sql: ${TABLE}.prev_custom_week ;;
}
# ... other dimensions for quarters, weeks, periods, seasons, etc. ...
# Example placeholder dimensions for unused timeframes
dimension: season {
type: string
sql: 'N/A' ;;
hidden: yes
}
dimension: season_num {
type: number
sql: 0 ;;
hidden: yes
}
}