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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

How to count the number of boolean "1" based on criteria?

Hi, I have two tables; table 1 and table 2.

 

I am trying to count the number of rows containing "1" on the shift count column from table 1 on table 2's total shifts column BASED on staff's name in table 2's staff column.

 

Here is table 1 and Total Shifts column shows the outcome that I want from the DAX expression:

StaffTotal Shifts
Name12
Name21

 

Here is table 2:

StaffShift Count
Name11
Name20
Name10
Name21
Name11

 

The DAX expressions that im using are Counta and Filter. It did not work and I get an error message "Dax Comparison operations do not support comparing values of type Integer with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values":

 

Please note, shift count column's data type is whole number.

 

Total Shift =
CALCULATE(
    COUNTA('Table 2'[Shift Count]),
            (FILTER(ALL('Table 2'),
            'Table 2'[Shift Count] = 'Table 1'[Staff])
            )
)

 

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

Hi @Anonymous 

Try this

Total Shift =
CALCULATE(
    SUM('Table 2'[Shift Count]),
            (FILTER(ALL('Table 2'),
            'Table 2'[Staff] = 'Table 1'[Staff])
            )
)

Please mark the question solved when done and consider giving kudos if posts are helpful.

 Cheers 

SU18_powerbi_badge

View solution in original post

2 REPLIES 2
AlB
Community Champion
Community Champion

Hi @Anonymous 

Try this

Total Shift =
CALCULATE(
    SUM('Table 2'[Shift Count]),
            (FILTER(ALL('Table 2'),
            'Table 2'[Staff] = 'Table 1'[Staff])
            )
)

Please mark the question solved when done and consider giving kudos if posts are helpful.

 Cheers 

SU18_powerbi_badge

Anonymous
Not applicable

Even better is this:

 

Total Shift = // calculated column in Table 1
CALCULATE(
    SUM('Table 2'[Shift Count]),
    'Table 2'[Staff] = SELECTEDVALUE( 'Table 1'[Staff] )
)

 

 

Best

D

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.