[{"id":"840f0737-df1d-47ae-bb0a-359b01fe0608","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"d5d9cdef-8854-4505-89be-a2bbc3cb4482","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"3dc3dd55-35b0-4d23-bf62-47bc3650e4ee","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"80d84fbc-d0f8-4e4a-947f-e3e4de9b49b2","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"9152b7ca-0186-4fe3-a26f-5a05f322db07","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]}]
        
(Showing Draft Content)

基于计算结果将字段分类

需求描述

根据计算结果添加一个新的类别字段。

比如根据销售额的大小来计算,如果销售额<1000000,则字段值为'good',如果12000000>sales amount>=1000000,则字段值为'better',如果销售额金额 >=12000000,字段值为“best”。

在仪表板中实现

1. 添加一个透视表,并在行和数值中绑定字段。

image2021-12-15_16-38-29.png


2. 在表 'FactResllerSales' 上添加一个度量值。

image2021-12-15_16-40-34.png


3. 输入表达式的名称,和表达式内容并保存。

switch(true,sum('FactResellerSales'[SalesAmount]) < 1000000,"good",sum('FactResellerSales'[SalesAmount])>=1000000 && sum('FactResellerSales'[SalesAmount]) <12000000,"better" ('FactResellerSales'[SalesAmount]) >=12000000,"best")

这里是用switch函数来实现的,您也可以用 if 函数来做同样的事情。

image2021-12-15_16-42-20.png


4. 将新建的度量值绑定到数值中。

image2021-12-15_16-45-24.png