analytics/pbi/model/report/Model/tables/Партнер.tmdl
2026-02-18 14:36:38 +03:00

276 lines
9.5 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

table Партнер
measure 'ABC Class dynamic' =
IF (
HASONEVALUE ( 'Партнер'[partner_id] ),
VAR SalesByPartner =
CALCULATETABLE (
ADDCOLUMNS (
SUMMARIZE ( 'Партнер', 'Партнер'[partner_id] ),
"@PartnerSales", [Сумма продаж + РК, руб]
),
ALLSELECTED ( 'Партнер' )
)
VAR AllSales =
CALCULATE (
[Сумма продаж + РК, руб],
ALLSELECTED ( 'Партнер' )
)
VAR CurrentSalesAmt = [Сумма продаж + РК, руб]
VAR CumulatedSales =
FILTER (
SalesByPartner,
[@PartnerSales] >= CurrentSalesAmt
)
VAR CumulatedSalesAmount =
SUMX (
CumulatedSales,
[@PartnerSales]
)
VAR CurrentCumulatedPct =
DIVIDE (
CumulatedSalesAmount,
AllSales
)
VAR Result =
SWITCH (
TRUE,
ISBLANK ( CurrentCumulatedPct ), BLANK (),
CurrentCumulatedPct <= 0.8, "A",
CurrentCumulatedPct <= 0.95, "B",
"C"
)
RETURN
Result
)
column partner_id
dataType: string
isHidden
summarizeBy: none
sourceColumn: partner_id
changedProperty = IsHidden
annotation SummarizationSetBy = Automatic
column Партнер
dataType: string
summarizeBy: none
sourceColumn: Партнер
changedProperty = SortByColumn
annotation SummarizationSetBy = Automatic
column Регион
dataType: string
summarizeBy: none
sourceColumn: Регион
annotation SummarizationSetBy = Automatic
column manager_id
dataType: string
isHidden
summarizeBy: none
sourceColumn: manager_id
changedProperty = IsHidden
annotation SummarizationSetBy = Automatic
column 'Да/Нет Клиент'
dataType: int64
formatString: 0
summarizeBy: sum
sourceColumn: Да/Нет Клиент
annotation SummarizationSetBy = Automatic
column 'Да/Нет Поставщик'
dataType: int64
formatString: 0
summarizeBy: sum
sourceColumn: Да/Нет Поставщик
annotation SummarizationSetBy = Automatic
column 'Да/Нет Конкурент'
dataType: int64
formatString: 0
summarizeBy: sum
sourceColumn: Да/Нет Конкурент
annotation SummarizationSetBy = Automatic
column 'Код УТ'
dataType: string
summarizeBy: none
sourceColumn: Код УТ
annotation SummarizationSetBy = Automatic
column 'Основной менеджер'
dataType: string
isHidden
summarizeBy: none
sourceColumn: Основной менеджер
changedProperty = IsHidden
annotation SummarizationSetBy = Automatic
column 'Направление деятельности'
dataType: string
summarizeBy: none
sourceColumn: Направление деятельности
annotation SummarizationSetBy = Automatic
column bitrix_id
dataType: string
isHidden
summarizeBy: none
sourceColumn: bitrix_id
changedProperty = IsHidden
annotation SummarizationSetBy = Automatic
column ДатаРегистрации
dataType: dateTime
formatString: General Date
summarizeBy: none
sourceColumn: ДатаРегистрации
variation Изменение
isDefault
relationship: 70d8fb19-ce6e-4331-bdd5-c48b97661c3a
defaultHierarchy: LocalDateTable_67da7b50-915b-480b-9e3a-3a60739fb0c6.'Иерархия дат'
annotation SummarizationSetBy = Automatic
column Сегмент
dataType: string
summarizeBy: none
sourceColumn: Сегмент
annotation SummarizationSetBy = Automatic
column 'Дата последнего звонка'
dataType: dateTime
formatString: Long Date
summarizeBy: none
sourceColumn: Дата последнего звонка
variation Изменение
isDefault
relationship: b7780e24-ae05-4812-ad3f-b6d9dc7f50cc
defaultHierarchy: LocalDateTable_c661d468-0044-4990-b9e8-723cda59cf51.'Иерархия дат'
annotation SummarizationSetBy = Automatic
annotation UnderlyingDateTimeDataType = Date
column partner_link
dataType: string
dataCategory: WebUrl
summarizeBy: none
sourceColumn: partner_link
annotation SummarizationSetBy = Automatic
column Область
dataType: string
summarizeBy: none
sourceColumn: Область
annotation SummarizationSetBy = Automatic
column Округ
dataType: string
summarizeBy: none
sourceColumn: Округ
annotation SummarizationSetBy = Automatic
column 'Что шьют?'
dataType: string
summarizeBy: none
sourceColumn: Что шьют?
annotation SummarizationSetBy = Automatic
column Категория
dataType: string
summarizeBy: none
sourceColumn: Категория
annotation SummarizationSetBy = Automatic
column 'Статус партнера'
dataType: string
summarizeBy: none
sourceColumn: Статус партнера
annotation SummarizationSetBy = Automatic
column 'Дата первого заказа'
dataType: dateTime
formatString: Long Date
summarizeBy: none
sourceColumn: Дата первого заказа
variation Изменение
isDefault
relationship: 8171e79f-bfe6-4798-bb1a-98146553bada
defaultHierarchy: LocalDateTable_588ed205-7c5f-41f0-9bd7-0d82b2484f09.'Иерархия дат'
changedProperty = DataType
annotation SummarizationSetBy = Automatic
annotation UnderlyingDateTimeDataType = Date
column Когорта = FORMAT('Партнер'[Дата первого заказа], "YYYY-MM")
summarizeBy: none
annotation SummarizationSetBy = Automatic
column 'Статус по динамике 2025/2024'
dataType: string
summarizeBy: none
sourceColumn: Статус по динамике 2025/2024
annotation SummarizationSetBy = Automatic
column 'Статус по обороту 2025'
dataType: string
summarizeBy: none
sourceColumn: Статус по обороту 2025
annotation SummarizationSetBy = Automatic
partition Партнер-974763bd-dd7f-47ca-b4b6-800173f04370 = m
mode: import
source =
let
Источник = Sql.Database("prdsql", "mag_pbi"),
sales_w_partners = Источник{[Schema="pbi",Item="Партнеры"]}[Data],
#"Переименованные столбцы" = Table.RenameColumns(sales_w_partners,{{"partner", "Партнер"}, {"region", "Регион"}, {"konkurent", "Да/Нет Конкурент"}, {"client", "Да/Нет Клиент"}, {"supplier", "Да/Нет Поставщик"}, {"_Code", "Код УТ"}}),
#"Объединенные запросы" = Table.NestedJoin(#"Переименованные столбцы", {"bitrix_id"}, crm_company_uf, {"bitrix_id"}, "crm_company_uf", JoinKind.LeftOuter),
#"Развернутый элемент crm_company_uf" = Table.ExpandTableColumn(#"Объединенные запросы", "crm_company_uf", {"Дата последнего звонка"}, {"Дата последнего звонка"}),
#"Вставлено: объединенный столбец" = Table.AddColumn(#"Развернутый элемент crm_company_uf", "Сведено", each Text.Combine({"https://magok.bitrix24.ru/crm/company/details/", [bitrix_id], "/"}), type text),
#"Переименованные столбцы1" = Table.RenameColumns(#"Вставлено: объединенный столбец",{{"Сведено", "partner_link"}, {"oblast", "Область"}, {"okrug", "Округ"}, {"Category", "Категория"}})
in
#"Переименованные столбцы1"
annotation PBI_QueryRelationships = {"columnCount":10,"keyColumnNames":[],"queryRelationships":[],"columnIdentities":["Server.Database\\/2/SQL/1cnew;mag_reports/sales/sales.w_partners.{1c_id,0}","Server.Database\\/2/SQL/1cnew;mag_reports/sales/sales.w_partners.{partner_id,1}","Server.Database\\/2/SQL/1cnew;mag_reports/sales/sales.w_partners.{partner,2}","Server.Database\\/2/SQL/1cnew;mag_reports/sales/sales.w_partners.{region,3}","Server.Database\\/2/SQL/1cnew;mag_reports/sales/sales.w_partners.{1c_manager_id,4}","Server.Database\\/2/SQL/1cnew;mag_reports/sales/sales.w_partners.{manager_id,5}","Server.Database\\/2/SQL/1cnew;mag_reports/sales/sales.w_partners.{napravlenie,6}","Server.Database\\/2/SQL/1cnew;mag_reports/sales/sales.w_partners.{client,7}","Server.Database\\/2/SQL/1cnew;mag_reports/sales/sales.w_partners.{supplier,8}","Server.Database\\/2/SQL/1cnew;mag_reports/sales/sales.w_partners.{konkurent,9}"],"ColumnCount":10,"KeyColumnNames":[],"ColumnIdentities":["Server.Database\\/2/SQL/1cnew;mag_reports/sales/sales.w_partners.{1c_id,0}","Server.Database\\/2/SQL/1cnew;mag_reports/sales/sales.w_partners.{partner_id,1}","Server.Database\\/2/SQL/1cnew;mag_reports/sales/sales.w_partners.{partner,2}","Server.Database\\/2/SQL/1cnew;mag_reports/sales/sales.w_partners.{region,3}","Server.Database\\/2/SQL/1cnew;mag_reports/sales/sales.w_partners.{1c_manager_id,4}","Server.Database\\/2/SQL/1cnew;mag_reports/sales/sales.w_partners.{manager_id,5}","Server.Database\\/2/SQL/1cnew;mag_reports/sales/sales.w_partners.{napravlenie,6}","Server.Database\\/2/SQL/1cnew;mag_reports/sales/sales.w_partners.{client,7}","Server.Database\\/2/SQL/1cnew;mag_reports/sales/sales.w_partners.{supplier,8}","Server.Database\\/2/SQL/1cnew;mag_reports/sales/sales.w_partners.{konkurent,9}"],"RelationshipInfo":[]}
annotation PBI_ResultType = Table
annotation PBI_NavigationStepName = Навигация