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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Count by Group by

Hi, I need some help with a calculated column.

 

Following are the details:

client_idsurvey_idcomment_idcomment_textCount of Comments
12323478234835kjsysdihskf3
123234782357545fghfdhh3
123234782534535gfhfghdf3
1235788449594xvxvsd1
667438534434875xvcvxv2
6674385344367685fhdssh2
90565625326698734xvsgsg1

 

My goal is to calculate the count of comments for each survey. I could achieve this using the below calc column on my sample data. However, my real data comes from direct query and I am not able to use CALCULATE as it is not allowed with direct query. Is there a way or different approach to get this done ? 

 

Count of Comments = CALCULATE(COUNT(Table1[comment_id]), FILTER(Table1, Table1[survey_id] = EARLIER(Table1[survey_id])))

 

Appreciate your prompt help.

-SN

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

AFAIK, most of calculation DAX functions has been limited to use in direct query mode. You can use measure formula instead.

Measure =
CALCULATE (
    COUNTROWS ( VALUES ( 'Table'[comment_id] ) ),
    ALLSELECTED ( 'Table' ),
    VALUES ( 'Table'[client_id] ),
    VALUES ( 'Table'[survey_id] )
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
FrankAT
Community Champion
Community Champion

Hi @Anonymous ,

hope it helps, see figure:

 

20-04-_2020_22-59-57.png

 

Regards FrankAT

Anonymous
Not applicable

@FrankAT  Thanks for reply. The count column in my sample data is the result of the calculated column. I want that to be replicated for a direct query. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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