414 lines
11 KiB
Plaintext
414 lines
11 KiB
Plaintext
table Fact_Retail
|
|
lineageTag: 733ac3d1-ac4d-4a86-8462-77a051f2143c
|
|
|
|
measure 'Retail.test' = ```
|
|
|
|
SWITCH(TRUE(),
|
|
SELECTEDVALUE(Dim_DataSource[SOURCENAME]) = "Retail" &&
|
|
NOT SELECTEDVALUE(Dim_BrandDefaultMKT[MARKET]) IN {"NIAD (Non-Insulin Anti-Diabetic) Market","Inhaled Extended Market by Brand"} &&
|
|
ISFILTERED(Dim_PackInfo[PACK_DES]),1,
|
|
2)
|
|
```
|
|
lineageTag: 322170ba-03fc-430f-b867-bb96e56ed127
|
|
|
|
annotation PBI_FormatHint = {"isGeneralNumber":true}
|
|
|
|
column PACK_CODE
|
|
dataType: string
|
|
lineageTag: 3c3fcff9-c6f1-4c9f-b487-5099426db0d4
|
|
summarizeBy: none
|
|
sourceColumn: PACK_CODE
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column CORP_COD
|
|
dataType: string
|
|
lineageTag: 3dffb62e-7200-4c31-b85b-f5dfe6862eb1
|
|
summarizeBy: none
|
|
sourceColumn: CORP_COD
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column YYYYMM
|
|
dataType: string
|
|
lineageTag: df990200-a57e-431f-b233-ee80da20c422
|
|
summarizeBy: none
|
|
sourceColumn: YYYYMM
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column YTD
|
|
dataType: string
|
|
lineageTag: 7d8dadbc-c9de-4774-851f-4dd50d0e04cd
|
|
summarizeBy: none
|
|
sourceColumn: YTD
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column GEO_KEY
|
|
dataType: string
|
|
lineageTag: 75d8ed19-6013-42dc-a3e2-3313b7d82a44
|
|
summarizeBy: none
|
|
sourceColumn: GEO_KEY
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column KPI_NAME
|
|
dataType: string
|
|
lineageTag: 4a5785ed-e025-452b-8993-368fad267a22
|
|
summarizeBy: none
|
|
sourceColumn: KPI_NAME
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column TOTAL_FLAG
|
|
dataType: string
|
|
lineageTag: 30494dce-b119-43c4-8da9-43dc22bc6d86
|
|
summarizeBy: none
|
|
sourceColumn: TOTAL_FLAG
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column DATA_SOURCE
|
|
dataType: string
|
|
lineageTag: d673e814-e059-42f7-84cd-611cd3b9896d
|
|
summarizeBy: none
|
|
sourceColumn: DATA_SOURCE
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column KPI_VAL
|
|
dataType: double
|
|
lineageTag: 59170873-afc9-4a76-a108-bd65e8a34ebc
|
|
summarizeBy: sum
|
|
sourceColumn: KPI_VAL
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
annotation PBI_FormatHint = {"isGeneralNumber":true}
|
|
|
|
column KPI_VAL_LY
|
|
dataType: double
|
|
lineageTag: 4e107a73-4851-415a-8c97-37b594d20e9e
|
|
summarizeBy: sum
|
|
sourceColumn: KPI_VAL_LY
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
annotation PBI_FormatHint = {"isGeneralNumber":true}
|
|
|
|
column STR_KPI_VAL
|
|
dataType: string
|
|
lineageTag: f3f29a2c-8813-4f87-b31a-a13558cbe7f4
|
|
summarizeBy: none
|
|
sourceColumn: STR_KPI_VAL
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column STR_KPI_VAL_LY
|
|
dataType: string
|
|
lineageTag: faf10d00-be52-4e18-96d7-9712924144e3
|
|
summarizeBy: none
|
|
sourceColumn: STR_KPI_VAL_LY
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column KPI_VOL
|
|
dataType: double
|
|
lineageTag: 849b9c21-17d1-4db2-86bc-2baf068f338d
|
|
summarizeBy: sum
|
|
sourceColumn: KPI_VOL
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
annotation PBI_FormatHint = {"isGeneralNumber":true}
|
|
|
|
column KPI_VOL_LY
|
|
dataType: double
|
|
lineageTag: af535835-a00a-416b-b63e-c7c7dec8b695
|
|
summarizeBy: sum
|
|
sourceColumn: KPI_VOL_LY
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
annotation PBI_FormatHint = {"isGeneralNumber":true}
|
|
|
|
column STR_KPI_VOL
|
|
dataType: string
|
|
lineageTag: b4b3b6e5-2f04-495f-b2bf-fbfe8ac70485
|
|
summarizeBy: none
|
|
sourceColumn: STR_KPI_VOL
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column STR_KPI_VOL_LY
|
|
dataType: string
|
|
lineageTag: 901f6743-b6f0-4914-8688-82ea23b324e1
|
|
summarizeBy: none
|
|
sourceColumn: STR_KPI_VOL_LY
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column DATE_KEY = DATE(LEFT([YYYYMM],4),RIGHT([YYYYMM],2),"01")
|
|
formatString: General Date
|
|
lineageTag: 1e34272d-d21e-41c9-8aa1-d14c4e65e529
|
|
summarizeBy: none
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column AUDIT_SOURCE = [GEO_KEY] & [DATA_SOURCE]
|
|
lineageTag: dcf1d183-7e62-491b-a6c7-93a204de204a
|
|
summarizeBy: none
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column REGION_TYPE = ""
|
|
lineageTag: 291eb6fc-244c-42de-a12f-b532c7b82b40
|
|
summarizeBy: none
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column AUDIT_KEY = [GEO_KEY] & [DATA_SOURCE] & [REGION_TYPE]
|
|
lineageTag: ba25afcf-b936-4a4e-8803-2ad81ffebac1
|
|
summarizeBy: none
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column TA_SOURCE = [TA] & [DATA_SOURCE]
|
|
lineageTag: 04664e33-a533-44d4-a376-54da7a98e12b
|
|
summarizeBy: none
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column DTP_FLAG
|
|
dataType: int64
|
|
formatString: 0
|
|
lineageTag: 9ed47eeb-1462-468c-82de-43b33a1f82a9
|
|
summarizeBy: sum
|
|
sourceColumn: DTP_FLAG
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column TA
|
|
dataType: string
|
|
lineageTag: 95c9f941-2f02-43d4-b699-f2da8b2c490a
|
|
summarizeBy: none
|
|
sourceColumn: TA
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column pack_des = LOOKUPVALUE(Dim_PackInfo[PACK_DES],Dim_PackInfo[PACK_COD],Fact_Retail[PACK_CODE])
|
|
lineageTag: a33d5a7f-1eef-4781-af42-deb7adfea9c9
|
|
summarizeBy: none
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column prod_des = LOOKUPVALUE(Dim_PackInfo[PROD_DES_C],Dim_PackInfo[PACK_COD],Fact_Retail[PACK_CODE])
|
|
lineageTag: c7d79058-e3e2-480c-af42-e31adc2a0975
|
|
summarizeBy: none
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column 'prod or pack' =
|
|
|
|
VAR A= if(Fact_Retail[KPI_NAME]="brand_price"||Fact_Retail[KPI_NAME]="brand_price_by_counting_unit"||Fact_Retail[KPI_NAME]="num_dist_rate"||Fact_Retail[KPI_NAME]="weig_dist_rate"||Fact_Retail[KPI_NAME]="brand_price_fz"||Fact_Retail[KPI_NAME]="brand_price_by_counting_unit_fm"||Fact_Retail[KPI_NAME]="brand_price_fm",Fact_Retail[prod_des],Fact_Retail[pack_des])
|
|
RETURN
|
|
IF(
|
|
A=Fact_Retail[prod_des],"合计",A)
|
|
lineageTag: 008b0674-5fec-4817-b329-a1c70503bed8
|
|
summarizeBy: none
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column 'prod or pack 1' =
|
|
|
|
VAR A= if(Fact_Retail[KPI_NAME]="brand_price"||Fact_Retail[KPI_NAME]="brand_price_by_counting_unit"||Fact_Retail[KPI_NAME]="num_dist_rate"||Fact_Retail[KPI_NAME]="weig_dist_rate"||Fact_Retail[KPI_NAME]="brand_price_fz"||Fact_Retail[KPI_NAME]="brand_price_by_counting_unit_fm"||Fact_Retail[KPI_NAME]="brand_price_fm",Fact_Retail[prod_des],Fact_Retail[pack_des])
|
|
RETURN
|
|
A
|
|
lineageTag: 15d46b19-7e1b-49a6-b0c6-44327b230411
|
|
summarizeBy: none
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column 'prod or pack 2' =
|
|
|
|
VAR A= if(Fact_Retail[KPI_NAME]="brand_price"||Fact_Retail[KPI_NAME]="brand_price_by_counting_unit"||Fact_Retail[KPI_NAME]="num_dist_rate"||Fact_Retail[KPI_NAME]="weig_dist_rate"||Fact_Retail[KPI_NAME]="brand_price_fz"||Fact_Retail[KPI_NAME]="brand_price_by_counting_unit_fm"||Fact_Retail[KPI_NAME]="brand_price_fm",Fact_Retail[prod_des],Fact_Retail[pack_des])
|
|
RETURN
|
|
IF(
|
|
A=Fact_Retail[prod_des],a,blank())
|
|
lineageTag: 6832077e-8187-4e7f-9de2-468d0a81f587
|
|
summarizeBy: none
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column PACK_FLAG
|
|
dataType: int64
|
|
formatString: 0
|
|
lineageTag: 0980a952-226c-486f-8737-a123d3b8da7c
|
|
summarizeBy: sum
|
|
sourceColumn: PACK_FLAG
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column PROD_FLAG
|
|
dataType: int64
|
|
formatString: 0
|
|
lineageTag: bd45161f-101e-465b-b302-6de0e2b1a735
|
|
summarizeBy: sum
|
|
sourceColumn: PROD_FLAG
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column CORP_DES_C = RELATED(Dim_Corp[CORP_DES_C])
|
|
lineageTag: eadbb7a1-f323-4e7d-9fda-9e3f02e97af4
|
|
summarizeBy: none
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column PACK_CORP = [prod_des] &" "& [prod or pack] & "("& [CORP_DES_C]&")"
|
|
lineageTag: eb255404-4a7a-4569-a3c3-4f2c019add21
|
|
summarizeBy: none
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column PROD_CORP = [prod_des] & "(" & [CORP_DES_C] & ")"
|
|
lineageTag: 5d01b851-3f77-4a70-87cc-7b6b4c5b6b5c
|
|
summarizeBy: none
|
|
sortByColumn: PROD_RN
|
|
|
|
changedProperty = SortByColumn
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column PROD_RN = IF([prod_des] = "OTHERS",2,1)
|
|
formatString: 0
|
|
lineageTag: 4bef54a4-6b63-40b6-bec1-879a890e2835
|
|
summarizeBy: sum
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column PACK_SOURCE = [PACK_CODE] & [DATA_SOURCE]
|
|
lineageTag: b9d6fd23-5ef2-4924-b871-6cba7a32d833
|
|
summarizeBy: none
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column STR_KPI_VAL_EN
|
|
dataType: string
|
|
lineageTag: 8c2ec6d5-7c12-4933-bf08-bb0c56ac30db
|
|
summarizeBy: none
|
|
sourceColumn: STR_KPI_VAL_EN
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
partition Fact_Retail = m
|
|
mode: import
|
|
queryGroup: OLD\非首页直取KPI
|
|
source = ```
|
|
let
|
|
Source =
|
|
Value.NativeQuery(
|
|
Databricks.Catalogs(
|
|
ServerAddress, HttpPath, [
|
|
Catalog = CatalogName,
|
|
Database = null,
|
|
EnableAutomaticProxyDiscovery = null,EnableQueryResultDownload="0"
|
|
]
|
|
){
|
|
[Name = CatalogName, Kind = "Database"]
|
|
}[Data],
|
|
"
|
|
with dm_zk_retail_sales_kpi as (
|
|
SELECT
|
|
A.PACK_CODE,
|
|
A.CORP_COD,
|
|
TA,
|
|
YYYYMM,
|
|
YTD,
|
|
GEO_KEY,
|
|
KPI_NAME,
|
|
TOTAL_FLAG,
|
|
INT(DTP_FLAG) DTP_FLAG,
|
|
DATA_SOURCE,
|
|
SUM(CAST(KPI_VAL AS DECIMAL(38, 16))) KPI_VAL,
|
|
SUM(CAST(KPI_VAL_LY AS DECIMAL(38, 16))) KPI_VAL_LY,
|
|
MAX(STR_KPI_VAL) STR_KPI_VAL,
|
|
MAX(STR_KPI_VAL_LY) STR_KPI_VAL_LY,
|
|
SUM(CAST(KPI_VOL AS DECIMAL(38, 16))) KPI_VOL,
|
|
SUM(CAST(KPI_VOL_LY AS DECIMAL(38, 16))) KPI_VOL_LY,
|
|
MAX(STR_KPI_VOL) STR_KPI_VOL,
|
|
MAX(STR_KPI_VOL_LY) STR_KPI_VOL_LY,
|
|
MAX(PACK_FLAG) PACK_FLAG,
|
|
MAX(BRAND_FLAG) PROD_FLAG
|
|
FROM
|
|
dm.dm_zk_retail_sales_kpi A
|
|
GROUP BY
|
|
A.PACK_CODE,
|
|
A.CORP_COD,
|
|
TA,
|
|
YYYYMM,
|
|
YTD,
|
|
GEO_KEY,
|
|
KPI_NAME,
|
|
TOTAL_FLAG,
|
|
DATA_SOURCE,
|
|
DTP_FLAG
|
|
),
|
|
dim_pack AS (
|
|
SELECT
|
|
DISTINCT PROD_DES,
|
|
PROD_DES_C
|
|
FROM
|
|
DM.DM_TD_EXTERNAL_PACKINFO --where DATA_SOURCE = 'Retail(Quarterly)'
|
|
)
|
|
SELECT
|
|
PACK_CODE,
|
|
CORP_COD,
|
|
TA,
|
|
YYYYMM,
|
|
YTD,
|
|
GEO_KEY,
|
|
KPI_NAME,
|
|
TOTAL_FLAG,
|
|
DTP_FLAG,
|
|
DATA_SOURCE,
|
|
KPI_VAL,
|
|
KPI_VAL_LY,
|
|
STR_KPI_VAL,
|
|
STR_KPI_VAL_LY,
|
|
KPI_VOL,
|
|
KPI_VOL_LY,
|
|
STR_KPI_VOL,
|
|
STR_KPI_VOL_LY,
|
|
PACK_FLAG,
|
|
PROD_FLAG,
|
|
case
|
|
when KPI_NAME NOT in (
|
|
'top1_incremental_brand',
|
|
'top1_brand_val',
|
|
'top2_incremental_brand',
|
|
'top2_brand_val') then NULL
|
|
when ( SELECT MAX(PROD_DES) from dim_pack B where B.PROD_DES_C = A.STR_KPI_VAL ) is null then A.STR_KPI_VAL
|
|
ELSE ( SELECT MAX(PROD_DES) from dim_pack B where B.PROD_DES_C = A.STR_KPI_VAL )
|
|
end as STR_KPI_VAL_EN_1
|
|
FROM
|
|
dm_zk_retail_sales_kpi A
|
|
"
|
|
& UsingLimit,
|
|
null,
|
|
[
|
|
EnableFolding = true
|
|
]
|
|
),
|
|
#"Renamed Columns" = Table.RenameColumns(Source,{{"STR_KPI_VAL_EN_1", "STR_KPI_VAL_EN"}})
|
|
in
|
|
#"Renamed Columns"
|
|
```
|
|
|
|
annotation PBI_ResultType = Exception
|
|
|
|
annotation PBI_NavigationStepName = Navigation
|
|
|
|
annotation TabularEditor_TableGroup = 05_FactTable
|
|
|