Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!
Hi All,
I have a measure (1a) that calculates the no of hours that an employee has worked for the past 10 weeks.
I need another measure that flags that if they have worked more than 30 hours based on the above measure then flag as "1" on an employee level.
ANd finally when I roll up to the department level, it will sum the total no of employees that have "1" i.e. worked more than 30 hours.
I thought I could just write an if statement like: IF (1a. measure) > 30, then 1, 0) but I think you cannot have a measure as a condition... any suggestions would help!!!
Would be so grateful if someone could help.
Solved! Go to Solution.
Hey @Anonymous ,
yes, that's possible. But you need a filter context for the measure, so you have to create a virtual table of all employees first in the measure. Then you can add the measure for the virtual table or check your criteria there directly and at the end summarize your result and return it.
The following approach should work for you:
Number employees with more than 10 hours =
-- Returns a distinct list of Employees
VAR vAllEmployees = VALUES( myTable[Employee] )
-- Then you add the measure to that table
VAR vAddMeasure =
ADDCOLUMNS(
vAllEmployees,
"@MoreThan30Hours",
IF(
[measure hours that an employee has worked] > 30,
1,
0
)
)
RETURN
-- At the end you can sum up the amount of employees who worked more than 30 hours
SUMX(
vAddMeasure,
[@MoreThan30Hours]
)
[Your Measure] =
countrows(
filter(
summarize(
FactTable,
Employee[EmployeeID]
),
[1a. measure] > 30
)
)
[Your Measure] =
countrows(
filter(
summarize(
FactTable,
Employee[EmployeeID]
),
[1a. measure] > 30
)
)
Hey @Anonymous ,
yes, that's possible. But you need a filter context for the measure, so you have to create a virtual table of all employees first in the measure. Then you can add the measure for the virtual table or check your criteria there directly and at the end summarize your result and return it.
The following approach should work for you:
Number employees with more than 10 hours =
-- Returns a distinct list of Employees
VAR vAllEmployees = VALUES( myTable[Employee] )
-- Then you add the measure to that table
VAR vAddMeasure =
ADDCOLUMNS(
vAllEmployees,
"@MoreThan30Hours",
IF(
[measure hours that an employee has worked] > 30,
1,
0
)
)
RETURN
-- At the end you can sum up the amount of employees who worked more than 30 hours
SUMX(
vAddMeasure,
[@MoreThan30Hours]
)
The Power BI Data Visualization World Championships is back! It's time to submit your entry.
| User | Count |
|---|---|
| 50 | |
| 42 | |
| 36 | |
| 31 | |
| 29 |
| User | Count |
|---|---|
| 129 | |
| 129 | |
| 59 | |
| 48 | |
| 47 |