284 lines
7.6 KiB
Plaintext
284 lines
7.6 KiB
Plaintext
table Fact_Sales_Total
|
||
lineageTag: 66266824-1f74-413e-9407-eaefe5310c49
|
||
|
||
column YYYYMM
|
||
dataType: string
|
||
lineageTag: a21d6b7b-1fee-473f-b897-5576f106fbb5
|
||
summarizeBy: none
|
||
sourceColumn: YYYYMM
|
||
|
||
annotation SummarizationSetBy = Automatic
|
||
|
||
column SALES_UNIT_CAL
|
||
dataType: double
|
||
lineageTag: 9c702b06-b06e-453c-b013-744f8d03bec0
|
||
summarizeBy: sum
|
||
sourceColumn: SALES_UNIT_CAL
|
||
|
||
annotation SummarizationSetBy = Automatic
|
||
|
||
annotation PBI_FormatHint = {"isGeneralNumber":true}
|
||
|
||
column SALES_UNIT_CAL_LY
|
||
dataType: double
|
||
lineageTag: 7f7ce86d-eb5c-4130-96b2-4056ee5fad02
|
||
summarizeBy: sum
|
||
sourceColumn: SALES_UNIT_CAL_LY
|
||
|
||
annotation SummarizationSetBy = Automatic
|
||
|
||
annotation PBI_FormatHint = {"isGeneralNumber":true}
|
||
|
||
column SALES_VALUE_CAL
|
||
dataType: double
|
||
lineageTag: ad4a9b76-ca27-4435-94ae-adc3d9dbbe0a
|
||
summarizeBy: sum
|
||
sourceColumn: SALES_VALUE_CAL
|
||
|
||
annotation SummarizationSetBy = Automatic
|
||
|
||
annotation PBI_FormatHint = {"isGeneralNumber":true}
|
||
|
||
column SALES_VALUE_CAL_LY
|
||
dataType: double
|
||
lineageTag: d1de8632-e5f2-40bb-82d3-240e8699aff3
|
||
summarizeBy: sum
|
||
sourceColumn: SALES_VALUE_CAL_LY
|
||
|
||
annotation SummarizationSetBy = Automatic
|
||
|
||
annotation PBI_FormatHint = {"isGeneralNumber":true}
|
||
|
||
column CONUTING_UNIT
|
||
dataType: double
|
||
lineageTag: 243c84e7-50e5-4996-9b3e-06fbcab24285
|
||
summarizeBy: sum
|
||
sourceColumn: CONUTING_UNIT
|
||
|
||
annotation SummarizationSetBy = Automatic
|
||
|
||
annotation PBI_FormatHint = {"isGeneralNumber":true}
|
||
|
||
column CONUTING_UNIT_LY
|
||
dataType: double
|
||
lineageTag: 0be13c42-f1fc-4203-8698-80bbf13db95e
|
||
summarizeBy: sum
|
||
sourceColumn: CONUTING_UNIT_LY
|
||
|
||
annotation SummarizationSetBy = Automatic
|
||
|
||
annotation PBI_FormatHint = {"isGeneralNumber":true}
|
||
|
||
column DATA_SOURCE
|
||
dataType: string
|
||
lineageTag: da0e75b9-f9b2-48d8-812a-051aaaca736c
|
||
summarizeBy: none
|
||
sourceColumn: DATA_SOURCE
|
||
|
||
annotation SummarizationSetBy = Automatic
|
||
|
||
column DATE_KEY = DATE(LEFT([YYYYMM],4),RIGHT([YYYYMM],2),"01")
|
||
formatString: General Date
|
||
lineageTag: 98d2721b-1932-4b8e-8b96-df33b6e27753
|
||
summarizeBy: none
|
||
|
||
annotation SummarizationSetBy = Automatic
|
||
|
||
column REGION_TYPE
|
||
dataType: string
|
||
lineageTag: 7ce546d7-bfa2-45e4-bfa1-088d985553de
|
||
summarizeBy: none
|
||
sourceColumn: REGION_TYPE
|
||
|
||
annotation SummarizationSetBy = Automatic
|
||
|
||
column PLATFORM_TYPE
|
||
dataType: string
|
||
lineageTag: 2eb1c33a-a4be-4774-8d7c-38c4b74fb100
|
||
summarizeBy: none
|
||
sourceColumn: PLATFORM_TYPE
|
||
|
||
annotation SummarizationSetBy = Automatic
|
||
|
||
column STORE_TYPE
|
||
dataType: string
|
||
lineageTag: 2c6aefe8-00b9-4b3c-bead-2bbb926f8434
|
||
summarizeBy: none
|
||
sourceColumn: STORE_TYPE
|
||
|
||
annotation SummarizationSetBy = Automatic
|
||
|
||
column 'new store type' = SWITCH(Fact_Sales_Total[STORE_TYPE],"第三方","POP","品牌店","SO","平台店","SO","自营旗舰","SO",Fact_Sales_total[STORE_TYPE])
|
||
lineageTag: 50b3306b-98e1-4d6c-bce9-f64c50775d26
|
||
summarizeBy: none
|
||
|
||
annotation SummarizationSetBy = Automatic
|
||
|
||
column PLATFORM_TYPE_SOURCE = [PLATFORM_TYPE] & [DATA_SOURCE]
|
||
lineageTag: dd5a65dd-d9dd-403c-843c-19f7a4808a06
|
||
summarizeBy: none
|
||
|
||
annotation SummarizationSetBy = Automatic
|
||
|
||
column STORE_TYPE_SOURCE = [STORE_TYPE] & [DATA_SOURCE]
|
||
lineageTag: 86591690-31e1-40b6-b955-5540cb31a54a
|
||
summarizeBy: none
|
||
|
||
annotation SummarizationSetBy = Automatic
|
||
|
||
column MARKET
|
||
dataType: string
|
||
lineageTag: aad64764-08c9-4de6-bec4-657b8db4179c
|
||
summarizeBy: none
|
||
sourceColumn: MARKET
|
||
|
||
annotation SummarizationSetBy = Automatic
|
||
|
||
column PACK_COD
|
||
dataType: string
|
||
lineageTag: c3627711-3949-45c3-8660-c21b1ffddf4f
|
||
summarizeBy: none
|
||
sourceColumn: PACK_COD
|
||
|
||
annotation SummarizationSetBy = Automatic
|
||
|
||
column PDOT
|
||
dataType: double
|
||
lineageTag: c5e28608-997c-417f-84b6-ed5735cc98f4
|
||
summarizeBy: sum
|
||
sourceColumn: PDOT
|
||
|
||
annotation SummarizationSetBy = Automatic
|
||
|
||
annotation PBI_FormatHint = {"isGeneralNumber":true}
|
||
|
||
column PDOT_LY
|
||
dataType: double
|
||
lineageTag: c1254912-c548-452e-b465-6136745edb4c
|
||
summarizeBy: sum
|
||
sourceColumn: PDOT_LY
|
||
|
||
annotation SummarizationSetBy = Automatic
|
||
|
||
annotation PBI_FormatHint = {"isGeneralNumber":true}
|
||
|
||
column MKT_SOURCE
|
||
dataType: string
|
||
lineageTag: 4ffdfaef-8975-441a-b36d-cb747964892c
|
||
summarizeBy: none
|
||
sourceColumn: MKT_SOURCE
|
||
|
||
annotation SummarizationSetBy = Automatic
|
||
|
||
column CLASS
|
||
dataType: string
|
||
lineageTag: 60b25ddc-8118-4cf5-890b-4497b6dc3bc8
|
||
summarizeBy: none
|
||
sourceColumn: CLASS
|
||
|
||
annotation SummarizationSetBy = Automatic
|
||
|
||
partition Fact_Sales_Total = m
|
||
mode: import
|
||
queryGroup: Fact_Sales
|
||
source = ```
|
||
let
|
||
Source =
|
||
Value.NativeQuery(
|
||
Databricks.Catalogs(
|
||
ServerAddress, HttpPath, [
|
||
Catalog = CatalogName,
|
||
Database = null,
|
||
EnableAutomaticProxyDiscovery = null,EnableQueryResultDownload="0"
|
||
]
|
||
){
|
||
[Name = CatalogName, Kind = "Database"]
|
||
}[Data],
|
||
"
|
||
WITH base AS (
|
||
-- 下推过滤,主表只扫一次
|
||
SELECT *
|
||
FROM DM.dm_tf_ext_unionall_sales_mapping
|
||
WHERE YYYYMM >= (YEAR(CURRENT_DATE()) - 3) * 100 + 1
|
||
),
|
||
|
||
geo AS (
|
||
-- 小维表预聚合去重,配合 BROADCAST 使用
|
||
SELECT DISTINCT AUDIT_COD, PROVINCE_GROUP
|
||
FROM DM.dm_td_external_geo_type
|
||
WHERE DATA_SOURCE = 'IQVIA-COUNTY(Quarterly)'
|
||
AND PROVINCE_GROUP <> '全国'
|
||
)
|
||
|
||
-- Branch 1: 非季度数据,REGION_TYPE 置空
|
||
SELECT
|
||
YYYYMM,
|
||
MARKET,
|
||
CLASS,
|
||
PACK_COD,
|
||
PLATFORM_TYPE,
|
||
STORE_TYPE,
|
||
'' AS REGION_TYPE,
|
||
DATA_SOURCE,
|
||
concat(MARKET, DATA_SOURCE) AS MKT_SOURCE,
|
||
SUM(NULLIF(SALES_UNIT_CAL, 0)) AS SALES_UNIT_CAL,
|
||
SUM(NULLIF(SALES_UNIT_CAL_LY,0)) AS SALES_UNIT_CAL_LY,
|
||
SUM(NULLIF(SALES_VALUE_CAL, 0)) AS SALES_VALUE_CAL,
|
||
SUM(NULLIF(SALES_VALUE_CAL_LY,0)) AS SALES_VALUE_CAL_LY,
|
||
SUM(NULLIF(CONUTING_UNIT, 0)) AS CONUTING_UNIT,
|
||
SUM(NULLIF(CONUTING_UNIT_LY, 0)) AS CONUTING_UNIT_LY,
|
||
SUM(NULLIF(PDOT, 0)) AS PDOT,
|
||
SUM(NULLIF(PDOT_LY, 0)) AS PDOT_LY
|
||
FROM base
|
||
WHERE DATA_SOURCE NOT IN ('XH Data(Quarterly)', 'IQVIA-COUNTY(Quarterly)','AIA(Monthly)')
|
||
GROUP BY
|
||
YYYYMM, MARKET, CLASS, PACK_COD,
|
||
PLATFORM_TYPE, STORE_TYPE, DATA_SOURCE
|
||
|
||
UNION ALL
|
||
|
||
-- Branch 2: IQVIA 季度数据,关联省份分组
|
||
SELECT /*+ BROADCAST(geo) */
|
||
A.YYYYMM,
|
||
A.MARKET,
|
||
A.CLASS,
|
||
A.PACK_COD,
|
||
'' as PLATFORM_TYPE,
|
||
'' as STORE_TYPE,
|
||
coalesce(B.PROVINCE_GROUP, '') AS REGION_TYPE,
|
||
A.DATA_SOURCE,
|
||
concat(A.MARKET, A.DATA_SOURCE) AS MKT_SOURCE,
|
||
SUM(NULLIF(A.SALES_UNIT_CAL, 0)) AS SALES_UNIT_CAL,
|
||
SUM(NULLIF(A.SALES_UNIT_CAL_LY,0)) AS SALES_UNIT_CAL_LY,
|
||
SUM(NULLIF(A.SALES_VALUE_CAL, 0)) AS SALES_VALUE_CAL,
|
||
SUM(NULLIF(A.SALES_VALUE_CAL_LY,0)) AS SALES_VALUE_CAL_LY,
|
||
SUM(NULLIF(A.CONUTING_UNIT, 0)) AS CONUTING_UNIT,
|
||
SUM(NULLIF(A.CONUTING_UNIT_LY, 0)) AS CONUTING_UNIT_LY,
|
||
SUM(NULLIF(A.PDOT, 0)) AS PDOT,
|
||
SUM(NULLIF(A.PDOT_LY, 0)) AS PDOT_LY
|
||
FROM base A
|
||
LEFT JOIN geo B
|
||
ON A.AUDIT_COD = B.AUDIT_COD
|
||
WHERE A.DATA_SOURCE = 'IQVIA-COUNTY(Quarterly)'
|
||
GROUP BY
|
||
A.YYYYMM, A.MARKET, A.CLASS, A.PACK_COD,
|
||
A.DATA_SOURCE,
|
||
coalesce(B.PROVINCE_GROUP, '')
|
||
"
|
||
& UsingLimit,
|
||
null,
|
||
[
|
||
EnableFolding = true
|
||
]
|
||
)
|
||
in
|
||
Source
|
||
```
|
||
|
||
annotation PBI_ResultType = Exception
|
||
|
||
annotation PBI_NavigationStepName = Navigation
|
||
|
||
annotation TabularEditor_TableGroup = 05_FactTable
|
||
|