102 lines
2.4 KiB
Plaintext
102 lines
2.4 KiB
Plaintext
table Dim_Class
|
|
lineageTag: 5c9e5bd8-bf81-4518-85df-5ca516d61579
|
|
|
|
column CLASS
|
|
dataType: string
|
|
lineageTag: e9d468f0-e287-44df-9653-c1386fd9c679
|
|
summarizeBy: none
|
|
sourceColumn: CLASS
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column DATA_SOURCE
|
|
dataType: string
|
|
lineageTag: 01aa8f62-31ef-4a96-a9e6-3cf8b67d614d
|
|
summarizeBy: none
|
|
sourceColumn: DATA_SOURCE
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column CLASS_RN
|
|
dataType: int64
|
|
formatString: 0
|
|
lineageTag: a626486b-2a89-4dd2-a496-254ed0597b98
|
|
summarizeBy: sum
|
|
sourceColumn: CLASS_RN
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column CLASS_SOURCE = [MARKET] & [CLASS] & [DATA_SOURCE]
|
|
lineageTag: dd285249-6792-46a7-bfc1-8155f901672c
|
|
summarizeBy: none
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
column MARKET
|
|
dataType: string
|
|
lineageTag: 07163740-aaea-4591-9668-7b6628348d25
|
|
summarizeBy: none
|
|
sourceColumn: MARKET
|
|
|
|
annotation SummarizationSetBy = Automatic
|
|
|
|
partition Dim_Class = m
|
|
mode: import
|
|
queryGroup: Dim
|
|
source = ```
|
|
let
|
|
Source =
|
|
Value.NativeQuery(
|
|
Databricks.Catalogs(
|
|
ServerAddress, HttpPath, [
|
|
Catalog = CatalogName,
|
|
Database = null,
|
|
EnableAutomaticProxyDiscovery = null,EnableQueryResultDownload="0"
|
|
]
|
|
){
|
|
[Name = CatalogName, Kind = "Database"]
|
|
}[Data],
|
|
"
|
|
WITH class_sales AS (
|
|
-- 第一步:聚合,得到每个 class 的总销售额
|
|
SELECT
|
|
class,
|
|
SUM(SALES_VALUE_CAL) AS total_sales
|
|
FROM dm.dm_tf_ext_unionall_market_sales
|
|
WHERE DATA_SOURCE = 'IQVIA-CHPA(Monthly)'
|
|
GROUP BY class
|
|
),
|
|
class_rn AS (
|
|
-- 第二步:按总销售额排序,生成行号
|
|
SELECT
|
|
class,
|
|
ROW_NUMBER() OVER (ORDER BY total_sales) AS rn
|
|
FROM class_sales
|
|
)
|
|
SELECT /*+ BROADCAST(R) */
|
|
DISTINCT
|
|
L.MARKET,
|
|
L.CLASS,
|
|
L.DATASOURCE AS DATA_SOURCE,
|
|
COALESCE(R.rn, 99) AS CLASS_RN
|
|
FROM dm.dm_td_ext_unionall_market_pack_mapping L
|
|
LEFT JOIN class_rn R
|
|
ON L.CLASS = R.CLASS
|
|
"
|
|
& UsingLimit,
|
|
null,
|
|
[
|
|
EnableFolding = true
|
|
]
|
|
)
|
|
in
|
|
Source
|
|
```
|
|
|
|
annotation PBI_ResultType = Table
|
|
|
|
annotation PBI_NavigationStepName = Navigation
|
|
|
|
annotation TabularEditor_TableGroup = 04_DimTable
|
|
|