Summarized table column being recognized

huangapple go评论83阅读模式
英文:

Summarized table column being recognized

问题

I am trying to add a filter to my final output count using an aggregate column added to a summarized table. The dax formula isn't recognizing the aggregate column as valid. I am not sure what I am doing wrong here. tbl[Arrests] is the problem.

VAR tbl =
SUMMARIZE(
dimEmployee,
dimEmployee[wkEmployee],
"Arrests", DISTINCTCOUNT(dimBookingEvent[BookingSystemId])
)
var individualsMultipleArrest = CALCULATE(COUNTROWS(tbl), tbl[Arrests] > 1)

RETURN
individualsMultipleArrest

英文:

I am trying to add a filter to my final output count using an aggregate column added to a summarized table. The dax formula isn't recognizing the aggregate column as valid. I am not sure what I am doing wrong here.tbl[Arrests] is the problem.

VAR tbl =
    SUMMARIZE(
        dimEmployee,
        dimEmployee[wkEmployee],
        "Arrests", DISTINCTCOUNT(dimBookingEvent[BookingSystemId])
    )
var individualsMultipleArrest = CALCULATE(COUNTROWS(tbl), tbl[Arrests] > 1)

RETURN
    individualsMultipleArrest

答案1

得分: 0

你遇到的问题是由DAX处理表格和表达式中生成的列的方式引起的。当你在DAX表达式中使用SUMMARIZE创建一个表格时,你不能直接引用这些列,就好像它们是现有数据模型的一部分。你需要在该表格的上下文中操作以访问这些列。

你需要在CALCULATE函数内部使用FILTER函数,以根据你想应用的条件来过滤tbl变量。

VAR tbl =
    SUMMARIZE(
        dimEmployee,
        dimEmployee[wkEmployee],
        "Arrests", DISTINCTCOUNT(dimBookingEvent[BookingSystemId])
    )
VAR individualsMultipleArrest = CALCULATE(
    COUNTROWS(tbl),
    FILTER(
        tbl,
        [Arrests] > 1
    )
)

RETURN
    individualsMultipleArrest
英文:

The issue you're encountering is due to the way DAX handles tables and columns generated within expressions. When you create a table inside a DAX expression using SUMMARIZE, you can't directly reference the columns as if they were part of the existing data model. You'll need to work within the context of that table to access the columns.

You need to use the FILTER function inside the CALCULATE to filter the tbl variable based on the conditions you want to apply.

VAR tbl =
    SUMMARIZE(
        dimEmployee,
        dimEmployee[wkEmployee],
        "Arrests", DISTINCTCOUNT(dimBookingEvent[BookingSystemId])
    )
VAR individualsMultipleArrest = CALCULATE(
    COUNTROWS(tbl),
    FILTER(
        tbl,
        [Arrests] > 1
    )
)

RETURN
    individualsMultipleArrest

huangapple
  • 本文由 发表于 2023年8月11日 00:59:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/76877864.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定