사용
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매개변수 블록은 기간별 측정항목이 있는 커스텀 캘린더에 사용되어 현재 주가 1일 때 이전 주를 처리하는 방법과 현재 일이 1일 때 이전 일을 처리하는 방법을 Looker에 알려줍니다.previous_ordinal_mapping매개변수는 Looker 26.8부터 선택사항입니다.
이 페이지의 예 섹션을 참고하세요.
LookML에서 커스텀 캘린더 테이블을 모델링한 후에는 커스텀 캘린더 뷰를 기반으로 측정기준 그룹type: custom_calendar을 만들 수 있습니다. 그러면 최종 사용자가 커스텀 캘린더 측정기준 기간을 사용하여 Explore 쿼리를 만들 수 있습니다.
reference_date
reference_date 매개변수는 2026-01-01과 같은 표준 캘린더 날짜를 제공하는 커스텀 캘린더 데이터베이스 테이블의 열에 매핑되는 커스텀 캘린더 뷰의 측정기준을 지정합니다.
reference_date 매개변수에 대한 다음 사항에 유의하세요.
- Looker는 데이터 테이블에서 커스텀 캘린더 테이블로의 조인을 계산하여 커스텀 기간을 사용하는 쿼리 결과를 제공하므로
reference_date는 필수입니다. 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 블록은 custom_date 및 custom_week Looker 기간을 이전 일과 이전 주가 지정된 커스텀 캘린더 데이터베이스 테이블의 열을 모델링하는 측정기준에 매핑합니다.
previous_ordinal_mapping: {
custom_date: field-ref
custom_week: field-ref
}
custom_date매개변수는 현재 일이 1일 때 이전 일을 처리하는 방법을 Looker에 알려줍니다.custom_week매개변수는 현재 주가 1일 때 이전 주를 처리하는 방법을 Looker에 알려줍니다.
previous_ordinal_mapping 매개변수는 Looker 26.8부터 선택사항입니다. previous_ordinal_mapping 블록이 생략되면 Looker는 52주 연도를 가정합니다. 여기서 1주차의 이전 값은 52이고 1일차의 이전 값은 364입니다.
필수 기간
timeframe_mapping 및 timeframe_ordinal_mapping의 기간 하위 매개변수는 필수입니다. custom_season과 같은 특정 기간이 커스텀 캘린더와 관련이 없는 경우에도 캘린더 뷰에서 자리표시자 측정기준을 정의하여 포함해야 합니다. 예를 들면 다음과 같습니다.
dimension: season {
type: string
sql: 'N/A' ;;
hidden: yes
}
dimension: season_num {
type: number
sql: 0 ;;
hidden: yes
}
예
다음은 fiscal_calendar_table이라는 커스텀 캘린더 테이블을 모델링하는 fiscal_calendar.view.lkml이라는 뷰 파일의 예입니다.
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
}
}