英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论