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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
SBR1D
Helper III
Helper III

understanding countx and sumx

Hi All

 

I am trying to understand how countx and sum x works. In the matrix how is the sum x example 1 total 279? 
The columns that use countx make sense
The In progress count column i don't get understand. Target has 3 learners in progress so why does it count 1 instead of 3?

 

Dax formulas - 

 

count x example 1 = COUNTX(LearningPlan,COUNT(LearningPlan[LearnerID]))

 

 

 

sum x example 1 = sumx(VALUES(LearningPlan[Employer name]),COUNT(LearningPlan[LearnerID]))

 

 

 

x test = sumx(VALUES(LearningPlan[Employer name]),[count_x test])

 

 

 

count_x test = COUNT(LearningPlan[LearnerID])

 

 

 

in progress count = COUNTX(VALUES(LearningPlan[EmployerID]),CALCULATE(COUNT(LearningPlan[EmployerID]),LearningPlan[Status] = "In Progress"))

 

 

 

SBR1D_0-1707910056029.png

Here is my sample data

LearnerIDLearnerNameStart DatePlanned EndStatusEmployerIDEmployer nameCompletion DateWithdrawal DateInclude in ILR?
1Bob J01/03/202019/06/2021Withdrawn1JD Sports 04/02/2020Yes
2Sidney D02/04/202021/07/2021Withdrawn1JD Sports 13/01/2021Yes
3Josh A01/03/202019/06/2021Withdrawn1JD Sports 19/06/2020Yes
4Christian R14/03/202002/07/2021Withdrawn1JD Sports 17/07/2020Yes
5Tommy H18/03/202106/07/2022Withdrawn2Barrys Emporium 10/06/2021Yes
6Bruce D19/09/202007/01/2022Withdrawn2Barrys Emporium 11/11/2020Yes
7James H16/09/202303/01/2025Withdrawn2Barrys Emporium 19/09/2023Yes
8Angus Y12/12/202001/04/2022Withdrawn2Barrys Emporium 03/03/2023Yes
9Marshall M03/09/201921/12/2020Withdrawn3Target 10/10/2020Yes
10Barry K15/06/202302/10/2024Withdrawn3Target 08/08/2023Yes
11Tony K30/04/201917/08/2020Withdrawn3Target 29/05/2019No
12Emily D11/01/202030/04/2021Withdrawn3Target 02/02/2020Yes
13Rebecca R08/12/202327/03/2025Withdrawn4McDonalds 11/04/2024Yes
14Jane S06/02/202326/05/2024Withdrawn4McDonalds 07/02/2023Yes
15Amy I17/01/202406/05/2025Withdrawn4McDonalds 11/05/2024Yes
16Erin S02/02/202322/05/2024Withdrawn4McDonalds 11/02/2023Yes
17Bertrina D01/02/202222/05/2026Withdrawn5KFC 17/02/2022Yes
18John D03/06/202221/09/2023Withdrawn5KFC 04/08/2022Yes
19Tim P03/07/202321/10/2025Withdrawn5KFC 10/07/2023No
20Maxine A11/11/202328/02/2025Withdrawn5KFC 07/12/2023Yes
21Jasmine P11/11/202324/04/2024In Progress2Barrys Emporium  No
22Jack D30/04/201910/12/2020In Progress5KFC  No
23Rob K01/01/201823/05/2023In Progress3Target  No
24Jessy J15/03/201723/05/2023In Progress3Target  No
25Chad M25/04/201728/02/2024In Progress3Target  No
26Mo I29/12/202306/03/2025In Proress10Burger King  Yes
27Jason N09/01/202406/06/2025In Progress11Gillete   Yes
28Jenny J22/12/202309/08/2025In Progress1JD Sports  Yes
29Tom D18/08/202304/01/2025Withdrawn266Harrys 05/01/2023Yes
30Courney K05/06/202309/11/2026Withdrawn267Wilkinson Sword 21/12/2023Yes
31Jonathan D07/01/202408/06/2025In Progress4McDonalds  Yes



Thanks in advance

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@SBR1D , Based on what I got. Check meaning in comment

Use calculate when you use calculation in expression when you use a formula else use measure

count x example 1 = COUNTX(LearningPlan,calculate(COUNT(LearningPlan[LearnerID]))) // This one just count the row value and count it again

Better to use COUNT(LearningPlan[LearnerID])

 

 


sum x example 1 = sumx(VALUES(LearningPlan[Employer name]),calculate(COUNT(LearningPlan[LearnerID]))) // Do the count till employee name level and post that sum

 

sumx(VALUES(LearningPlan[Employer name]),[count_x test])

// Do the count till employee name level and post that sum

 

in progress count = COUNTX(VALUES(LearningPlan[EmployerID]),CALCULATE(COUNT(LearningPlan[EmployerID]),LearningPlan[Status] = "In Progress"))
// Do the count till employee name level and post that count again, means every value will be treated as 1

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@SBR1D , Based on what I got. Check meaning in comment

Use calculate when you use calculation in expression when you use a formula else use measure

count x example 1 = COUNTX(LearningPlan,calculate(COUNT(LearningPlan[LearnerID]))) // This one just count the row value and count it again

Better to use COUNT(LearningPlan[LearnerID])

 

 


sum x example 1 = sumx(VALUES(LearningPlan[Employer name]),calculate(COUNT(LearningPlan[LearnerID]))) // Do the count till employee name level and post that sum

 

sumx(VALUES(LearningPlan[Employer name]),[count_x test])

// Do the count till employee name level and post that sum

 

in progress count = COUNTX(VALUES(LearningPlan[EmployerID]),CALCULATE(COUNT(LearningPlan[EmployerID]),LearningPlan[Status] = "In Progress"))
// Do the count till employee name level and post that count again, means every value will be treated as 1

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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