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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

If condition based on measure

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. 

2 ACCEPTED SOLUTIONS
selimovd
Super User
Super User

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]
    )

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

 

View solution in original post

Anonymous
Not applicable

 

[Your Measure] =
countrows(
  filter(
    summarize(
      FactTable,
      Employee[EmployeeID]
    ),
    [1a. measure] > 30
  )
)

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

 

[Your Measure] =
countrows(
  filter(
    summarize(
      FactTable,
      Employee[EmployeeID]
    ),
    [1a. measure] > 30
  )
)

 

selimovd
Super User
Super User

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]
    )

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.