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
PowerPaddy
Frequent Visitor

COUNTX(currentgroup( ) with multiple conditions

Hello Again,

 

I'm creating a new table that has a count of all the new policies by month...

 

PolCount = GROUPBY(
   PolicyData,
   PolicyData[Month Written],
   "Month Written Count", COUNTX(currentgroup(),PolicyData[TRANSACTIONCODE]))

 

However, the policy data has multiple transactions and I only want it to count those which are labled as "NEW".

How do I use the COUNTX function as a COUNTIFS function like I would in Excel?

 

Many thanks

1 ACCEPTED SOLUTION
v-huizhn-msft
Employee
Employee

Hi @PowerPaddy,

I test @TomMartens solution, it works fine, please create the new table using the formula below.

PolCount = GROUPBY(
   PolicyData,
   PolicyData[Month Written],
   "Month Written Count", COUNTX(currentgroup(),IF(PolicyData[label]="New",PolicyData[TRANSACTIONCODE],BLANK())))


Please feel free to ask if you still have any other issues. If you have resolved your problem, please mark the right/helpful reply as answer.

Best Regards,
Angelia

View solution in original post

3 REPLIES 3
v-huizhn-msft
Employee
Employee

Hi @PowerPaddy,

I test @TomMartens solution, it works fine, please create the new table using the formula below.

PolCount = GROUPBY(
   PolicyData,
   PolicyData[Month Written],
   "Month Written Count", COUNTX(currentgroup(),IF(PolicyData[label]="New",PolicyData[TRANSACTIONCODE],BLANK())))


Please feel free to ask if you still have any other issues. If you have resolved your problem, please mark the right/helpful reply as answer.

Best Regards,
Angelia

Anonymous
Not applicable

Hi Angelia,

 

I know this is an old discussion but I am having issues with GROUPBY and am trying to replicate what you did. Could you walkthrough the logic behind the IF statement ? I understand counting under the condition that [label] = "New" but what does "...PolicyData[TRANSACTIONCODE],BLANK()" do?

 

Thanks!

 

TomMartens
Super User
Super User

Hmm,

 

I guess this should work

 
...
COUNTX(currentgroup(),
  IF(PolicyData[Something] = "New"
    ,PolicyData[TRANSACTIONCODE]
    ,BLANK()
  )
)

Hope this works

 

Regards



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

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.