147 lines
5.1 KiB
Plaintext
147 lines
5.1 KiB
Plaintext
table Config_MarketRatio
|
|
lineageTag: 246bb2c8-ab30-4d25-a0d0-51951b46bb1a
|
|
|
|
column MARKET
|
|
dataType: string
|
|
lineageTag: d7619034-8051-4a7e-bdeb-fd680a4644b8
|
|
summarizeBy: none
|
|
sourceColumn: MARKET
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column PACK_COD
|
|
dataType: string
|
|
lineageTag: 7e1f1f9c-ebe1-4050-8c12-8a0c50adf6ff
|
|
summarizeBy: none
|
|
sourceColumn: PACK_COD
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column brandratio_countingunit_level
|
|
dataType: string
|
|
lineageTag: 4ab3d25d-feac-4e06-9a21-18891951a6b4
|
|
summarizeBy: none
|
|
sourceColumn: brandratio_countingunit_level
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
partition Config_MarketRatio = m
|
|
mode: import
|
|
queryGroup: OLD
|
|
source = ```
|
|
let
|
|
Source =
|
|
Value.NativeQuery(
|
|
Databricks.Catalogs(
|
|
ServerAddress, HttpPath, [
|
|
Catalog = CatalogName,
|
|
Database = null,
|
|
EnableAutomaticProxyDiscovery = null,EnableQueryResultDownload="0"
|
|
]
|
|
){
|
|
[Name = CatalogName, Kind = "Database"]
|
|
}[Data],
|
|
"
|
|
with all_pack_pack_property as (
|
|
select Market,Pack_cod,CMPS_COD from dm.dm_aia_pack_property group by 1,2,3
|
|
union
|
|
select Market,iqvia_pack_code,CMPS_COD from dm.dm_zk_ec_pack_property group by 1,2,3
|
|
union
|
|
select Market,PACK_COD,CMPS_COD from dm.dm_chc_pack_property group by 1,2,3
|
|
union
|
|
select Market,PACK_COD,CMPS_COD from dm.dm_thc_pack_property group by 1,2,3
|
|
union
|
|
select Market,PACK_COD,CMPS_COD from dm.dm_ext_county_td_pack_property group by 1,2,3
|
|
union
|
|
select Market,iqvia_pack_code,CMPS_COD from dm.dm_zk_retail_dtp_pack_property group by 1,2,3
|
|
union
|
|
select Market,iqvia_pack_code,CMPS_COD from dm.dm_zk_retail_pack_property group by 1,2,3
|
|
union
|
|
select Market,pack_cod,CMPS_COD from DWS.dws_ims_td_market_ratio group by 1,2,3)
|
|
,brand_ratio as (
|
|
SELECT distinct market,
|
|
CASE WHEN length(cmps_cod) < 6 THEN RIGHT(CONCAT('000000',cmps_cod),6) ELSE cmps_cod END AS cmps_cod,
|
|
cmps_des,
|
|
CASE WHEN length(pack_cod) < 12 and pack_cod REGEXP '^[0-9]' THEN RIGHT(CONCAT('000000000000',pack_cod),12) ELSE pack_cod END AS pack_cod,
|
|
pack_des,
|
|
level,
|
|
type,
|
|
ratio
|
|
from dwd.dwd_gnd_ims_tblBrandRatio
|
|
)
|
|
,match_data as(
|
|
select
|
|
t1.PACK_COD,
|
|
t1.MARKET
|
|
-- case when t6.ratio is not null then t1.market_ratio * t6.ratio
|
|
-- else t1.market_ratio * NVL(t7.ratio,1)
|
|
-- end as VALUE_MARKET_RATIO,
|
|
-- case when t2.ratio is not null then t1.market_ratio * t2.ratio
|
|
-- else t1.market_ratio * NVL(t3.ratio,1)
|
|
-- end as UNIT_MARKET_RATIO,
|
|
-- t1.market_ratio as COUNTINGUNIT_MARKET_RATIO,
|
|
-- case when t4.ratio is not null then t1.market_ratio * t4.ratio
|
|
-- else t1.market_ratio * NVL(t5.ratio,1)
|
|
-- end as PDOT_MARKET_RATIO
|
|
|
|
,case
|
|
when t6.PACK_COD is not null then t6.level
|
|
when t7.CMPS_COD is not null then t7.level else null end as brandratio_value_level
|
|
,case
|
|
when t2.PACK_COD is not null then t2.level
|
|
when t3.CMPS_COD is not null then t3.level else null end as brandratio_unit_level
|
|
,case
|
|
when t4.PACK_COD is not null then t4.level
|
|
when t5.CMPS_COD is not null then t5.level else null end as brandratio_countingunit_level
|
|
|
|
from all_pack_pack_property t1
|
|
--unit by Pack
|
|
left join (select * from brand_ratio where upper(type) = 'UNIT' and upper(Level) = 'PACK') t2
|
|
on t1.PACK_COD = t2.pack_cod
|
|
and t1.MARKET = t2.market
|
|
--unit by MOLECULE
|
|
left join (select * from brand_ratio where upper(type) = 'UNIT' and upper(Level) = 'MOLECULE') t3
|
|
on t1.CMPS_COD = t3.cmps_cod
|
|
and t1.MARKET = t3.market
|
|
--PDOT by Pack
|
|
left join (select * from brand_ratio where upper(type) = 'COUNTINGUNIT' and upper(Level) = 'PACK') t4
|
|
on t1.PACK_COD = t4.pack_cod
|
|
and t1.MARKET = t4.market
|
|
--PDOT by MOLECULE
|
|
left join (select * from brand_ratio where upper(type) = 'COUNTINGUNIT' and upper(Level) = 'MOLECULE') t5
|
|
on t1.CMPS_COD = t5.cmps_cod
|
|
and t1.MARKET = t5.market
|
|
--VALUE by Pack
|
|
left join (select * from brand_ratio where upper(type) = 'VALUE' and upper(Level) = 'PACK') t6
|
|
on t1.PACK_COD = t6.pack_cod
|
|
and t1.MARKET = t6.market
|
|
--VALUE by MOLECULE
|
|
left join (select * from brand_ratio where upper(type) = 'VALUE' and upper(Level) = 'MOLECULE') t7
|
|
on t1.CMPS_COD = t7.cmps_cod
|
|
and t1.MARKET = t7.market
|
|
)
|
|
select
|
|
MARKET
|
|
,PACK_COD
|
|
-- ,brandratio_value_level
|
|
-- ,brandratio_unit_level
|
|
,nvl(brandratio_countingunit_level,'Market') as brandratio_countingunit_level
|
|
from match_data
|
|
"
|
|
& UsingLimit,
|
|
null,
|
|
[
|
|
EnableFolding = true
|
|
]
|
|
)
|
|
in
|
|
Source
|
|
```
|
|
|
|
annotation PBI_NavigationStepName = Navigation
|
|
|
|
annotation PBI_ResultType = Table
|
|
|
|
annotation TabularEditor_TableGroup = 03_ConfigTable
|
|
|