Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
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:
Staff | Total Shifts |
Name1 | 2 |
Name2 | 1 |
Here is table 2:
Staff | Shift Count |
Name1 | 1 |
Name2 | 0 |
Name1 | 0 |
Name2 | 1 |
Name1 | 1 |
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.
Solved! Go to Solution.
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
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
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
User | Count |
---|---|
20 | |
14 | |
11 | |
8 | |
6 |
User | Count |
---|---|
23 | |
23 | |
20 | |
15 | |
10 |