是否可以将切片器用作DAX Summarize函数的参数? [英] Is it possible to use a slicer as a parameter to a DAX Summarize function?

查看:271
本文介绍了是否可以将切片器用作DAX Summarize函数的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个FactLosses表和一个DimAccumulation表。我将它们带入PowerBi,并放置了切片器,以选择我感兴趣的累积区域。

I have a FactLosses Table, and a DimAccumulation table. I have brought them into PowerBi and I have placed a slicer to choose which accumulation zones i am interested in.

一旦用户选择了区域,我想执行逐年对损失进行分组,然后将损失汇总成年桶。但是,仅在适用于用户选择的区域的数据上。

Once the user has selected the zones, i want to perform a group by year on the losses and sum the losses into year buckets. But only on the data that applies to the zones the user picked.

我正在使用以下DAX代码进行分组,就像这样……

I am using the following DAX code to do the group by like so...

表= SUMMARIZECOLUMNS(FactForwardLookingAccumulation [年],按年亏损,SUM(FactForwardLookingAccumulation [净损失,我们的份额美元]))

Table = SUMMARIZECOLUMNS(FactForwardLookingAccumulation[Year], "Losses By Year", SUM(FactForwardLookingAccumulation[Net Loss Our Share Usd]))

问题是新表始终产生相同的结果。即,当我更改应包括哪些累积风险时,对求和没有影响。 (它是整个表的总和)

The problem is the new table always produces the same result. i.e When i make changes to which accumulation perils should be included it makes no difference to the summation. (it is summing the entire table)

我想使用切片器过滤事实表,然后在过滤后的列表上运行DAX查询。

I'd like to use the slicer to filter the fact table and then have the DAX query run on the filtered list. Is this possible?

推荐答案

如果您希望这些表对报表中的过滤器或切片器作出响应,则不能将这些表写为显示在数据标签下的计算表,因为这些表是在进行任何过滤之前计算的。

If you want these tables to be responsive to filters or slicers on your report, then you can't write these as calculated tables that show up under the Data tab since those are computed before any filtering happens.

要获得所需的内容,您必须在测量,因为这些是对切片器的响应。如果您要在完成分组和求和后查找最大损失年份,则可以按照以下方式编写度量:

To get what you want, you have to do everything inside of a measure, since those are what respond to slicers. If you're looking for the max loss year once the grouping and summing are completed, you can write a measure along these lines:

Year Max =
    VAR CalculatedTable = SUMMARIZECOLUMNS(FactForwardLookingAccumulation[Year], "Losses By Year", SUM(FactForwardLookingAccumulation[Net Loss Our Share Usd]))
    RETURN MAXX(CalculatedTable, [Losses By Year])

以这种方式编写将使计算出的表能够响应您的切片器和过滤器。

Writing it this way will allow the calculated table to respond to your slicers and filters.

这篇关于是否可以将切片器用作DAX Summarize函数的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆