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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
sun-and-sea
Frequent Visitor

Combine Group By with CountIf in one formula using Power Query M

Hi everyone

 

I modified the formula from the following thread: Solved: Re: CountIf with Group by in Power Query - Microsoft Power BI Community for my use case below.

 

I'm trying to group by all the publications (count total publications) but also count the number of values where Clicked = 1. It did return the results but I wasn't sure if it's working correctly. Can you confirm?

sunandsea_0-1629823030774.png

 

= Table.Group(Table.SelectRows(Table.SelectColumns(#"External contacts only",{"OnePlace__Publication__c","Clicked__c"}),each [Clicked__c]=1), {"OnePlace__Publication__c"}, {{"Count Clicked__c", each Table.RowCount(_), type number}})

 

Thank you,

Kara

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi  @sun-and-sea ,

 

As tested here,seems there is some problem,the result is not correct,I modify the M codes as below:

 

 

= Table.AddColumn(#"Changed Type", "Custom", each Table.RowCount(Table.SelectRows(#"Changed Type",(x)=>x[Category]=[Category] and x[Click]=1)))

 

 

And you will see:

vkellymsft_0-1630049519280.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my reply as a solution!

View solution in original post

1 REPLY 1
v-kelly-msft
Community Support
Community Support

Hi  @sun-and-sea ,

 

As tested here,seems there is some problem,the result is not correct,I modify the M codes as below:

 

 

= Table.AddColumn(#"Changed Type", "Custom", each Table.RowCount(Table.SelectRows(#"Changed Type",(x)=>x[Category]=[Category] and x[Click]=1)))

 

 

And you will see:

vkellymsft_0-1630049519280.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my reply as a solution!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors