This commit is contained in:
2026-04-15 10:36:20 +08:00
parent 43527d6c98
commit f1903bf7bb
811 changed files with 46977 additions and 41706 deletions

View File

@@ -150,3 +150,119 @@ expression Fact_Sales_SQL_limit =
annotation PBI_ResultType = Text
expression Config_MarketRatio = ```
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
```
lineageTag: f3952339-ada3-47e3-8e8e-670264eff2ef
queryGroup: OLD
annotation PBI_NavigationStepName = Navigation
annotation PBI_ResultType = Table