[{"id":"bcb0874d-299b-448e-9552-9e9b25ef80dd","tags":[{"product":null,"links":null,"id":"ba7e818e-4f6b-4211-b1ac-58e3bafcf439","name":"\u66F4\u65B0","color":"orange","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"8ce3627e-9e58-471b-9133-4f135d191e7b","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"ae60ae59-34f5-4f32-a8eb-243ed1457543","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"3d4848c3-910f-4ffa-9153-60bb507334a9","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"133f4ca6-d951-4d65-a618-3dc6301266f7","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"de62ec1c-813e-40b1-8160-a4cd109afe64","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"2426c71d-8332-4cbd-a436-1ec4f8666464","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"2ce7b6b0-78aa-4e4b-bf8a-e4ba2f988298","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"4706db46-0811-4652-8f59-1e0a1da84758","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"8f1271bb-2cd9-4f39-9897-c15b239ee7ab","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"677e13a7-6f3e-449f-986c-2c3a26f8d54f","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"5e40f6dc-caec-49d7-a1d0-be65f06815ba","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"2457f0e0-9e71-4860-a87d-065e0fb84f84","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"d5c67fd0-1145-482c-9113-97b492c44c18","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"a609a8fa-ab91-4c1d-a1c3-d209d0463303","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"b4a9eb15-94e5-48df-b218-a24138f0cf9c","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]}]
在已修改的筛选器上下文中计算表达式。
分析表达式
CALCULATE(<expression>[, <filter1> [, <filter2> [, …]]])
参数 | 定义 |
---|---|
expression | 要进行求值的表达式。 |
filter1, filter2,… | (可选)定义筛选器或筛选器调整函数的布尔表达式或表表达式。 |
用作第一个参数的表达式与度量基本相同,第一个参数可以是计算表达式。
筛选器可以是:
布尔筛选表达式
表筛选表达式
筛选器调整函数
当有多个筛选表达式时,可以使用 AND (&&) 逻辑运算符对它们进行计算,这意味着所有条件都必须为 TRUE。
布尔筛选表达式示例
分析表达式
CALCULATE (
SUM ( Sales[Sales Amount] ),
'Sales'[OrderDateKey] > 1 && 'Sales'[OrderDateKey] <100
)
表筛选表达式示例
表表达式筛选器将表对象应用为筛选器。 它可以是对模型表的引用,但更有可能是返回表对象的函数。
分析表达式
CALCULATE (
SUM ( Sales[Sales Amount] ),
Filter('Sales','Sales'[OrderDateKey] > 1 && 'Sales'[OrderDateKey] <100)
)
布尔过滤器和表过滤器之间的区别。
类型 | 描述 |
---|---|
布尔筛选表达式 | 此过滤器作为 where 子句,添加在连接表之后。 |
表筛选表达式 | 此过滤器作为表将进行内部连接。 |
筛选器调整函数
通过筛选器调整函数,不仅仅可以添加筛选器。 它们还在修改筛选器上下文时为您提供额外的控制。
在此版本中,我们仅提供“REMOVEFILTERS”功能。它只能去除不必要的维度。示例如下。
在计算Sales Amount合计时,忽略维度CustomerName。在实际使用时经常作为分母计算总的销售额。
分析表达式
CALCULATE (
SUM ( Sales[Sales Amount] ),
REMOVEFILTERS('Sale'[CustomerName])
)
返回表达式的计算结果。
计算满足三个筛选条件时的Sales Amount 合计。
分析表达式
CALCULATE (
SUMX ('Sales', Sales[Sales Amount] ),
'Sales'[OrderKey] > 20 && 'Sales'[OrderKey] <1010,
Filter('Sales','Sales'[OrderDateKey] > 1 && 'Sales'[OrderDateKey] <100),
REMOVEFILTERS('Sale'[CustomerName])
)
所有的过滤表达式都会作用于第一个参数的内表。这意味着 CALCULATE 函数中的过滤器表达式是一个预过滤器。