Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Filter calculate table / summarize by aggregate function column

Hello,

I created a table using CALCULATETABLE and SUMMARIZE, trying to count the number of people who answered my question more then once, but my code is not working:

 

Test Doubled hcps =
var DoubledHCPSTable = CALCULATETABLE(
SUMMARIZE(
'Calls Analsis',
'Calls Analsis'[sm_id],
'Calls Analsis'[QuestionID],
"Total Answers",COUNTA('Calls Analsis'[Answer])
)
,FILTER('Calls Analsis','Calls Analsis'[QuestionID]="i204")
)

RETURN CALCULATE(
COUNTROWS(DoubledHCPSTable),DoubledHCPSTable[Total Answers]>1)
)
 
How can I filter by the aggregate colum?
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Here is the answer: 

Test Doubled hcps = COUNTROWS(
FILTER(CALCULATETABLE(SUMMARIZE(
'Calls Analsis',
'Calls Analsis'[sm_id],
'Calls Analsis'[QuestionID],
"Total Answers",COUNTA('Calls Analsis'[Answer] )
)),'Calls Analsis'[QuestionID]="i204" && [Total Answers]>1 ))

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Here is the answer: 

Test Doubled hcps = COUNTROWS(
FILTER(CALCULATETABLE(SUMMARIZE(
'Calls Analsis',
'Calls Analsis'[sm_id],
'Calls Analsis'[QuestionID],
"Total Answers",COUNTA('Calls Analsis'[Answer] )
)),'Calls Analsis'[QuestionID]="i204" && [Total Answers]>1 ))

struggled and figured it out by oneslef would be the best. 

FreemanZ
Super User
Super User

Hi @Anonymous 

the last ) seems unnecessary. What warning do you get?

Anonymous
Not applicable

I deleted the last ) but I get: 

"cannot find table 'DoubledHCPSTable'" 

try to delete the DoubledHCPSTable:

Test Doubled hcps =
var DoubledHCPSTable = CALCULATETABLE(
SUMMARIZE(
'Calls Analsis',
'Calls Analsis'[sm_id],
'Calls Analsis'[QuestionID],
"Total Answers",COUNTA('Calls Analsis'[Answer])
)
,FILTER('Calls Analsis','Calls Analsis'[QuestionID]="i204")
)
RETURN CALCULATE(
COUNTROWS(DoubledHCPSTable),[Total Answers]>1)
 
p.s.: no need to specify the table name for virtually added column.
Anonymous
Not applicable

This also not working for me:

 

Test Doubled hcps =
var DoubledHCPSTable = CALCULATETABLE(
SUMMARIZE(
'Calls Analsis',
'Calls Analsis'[sm_id],
'Calls Analsis'[QuestionID],
"Total Answers",COUNTA('Calls Analsis'[Answer])
)
,FILTER('Calls Analsis','Calls Analsis'[QuestionID]="i204" && [Total Answers]>1)
)
RETURN CALCULATE(
COUNTROWS(DoubledHCPSTable))
Anonymous
Not applicable

Not working:

haim89_0-1671284911904.png

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.