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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Aggregate-able calculated measure/column based on value of another measure/column

I have data of a list of employees with their overtime data by event date. I also have a date table with eventdate grouped into work week. I've created a calculated measure to calculate their overtime hour by work week as below:

 

Week OT = sumx(SUMMARIZE('Data Table','Data Table'[Employee Name],'Date Table'[Work Week],"Week OT hrs",SUM('Data Table'[OT hrs])),[Week OT hrs])

 

This measure works fine and filterable by work week/employee name.

 

I now need to create a measure to flag if the person's weekly overtime is over 20hrs.

 

Flag = IF([Week OT]>20,1,0)

 

My final purpose is to count the number of flags for each work week and this won't work because it can't be aggregated like the Week OT measure (see picture). It only evaluate the grand total and flag that as "1"

 

How do I do this? Thanks in advance for your help!

bi forum question.JPG

1 ACCEPTED SOLUTION
BILASolution
Solution Specialist
Solution Specialist

Hi @Anonymous

 

I hope this helps...

 

Measure = COUNTX
(
	FILTER
	(
		SUMMARIZE
		(
			'Data Table',
			'Data Table'[Employee Name],
			'Date Table'[Work Week],
			"Week OT hrs",SUM('Data Table'[OT hrs])
		),[Week OT hrs]>20
	),'Date Table'[Work Week]
)

Regards

BILASolution

View solution in original post

3 REPLIES 3
BILASolution
Solution Specialist
Solution Specialist

Hi @Anonymous

 

I hope this helps...

 

Measure = COUNTX
(
	FILTER
	(
		SUMMARIZE
		(
			'Data Table',
			'Data Table'[Employee Name],
			'Date Table'[Work Week],
			"Week OT hrs",SUM('Data Table'[OT hrs])
		),[Week OT hrs]>20
	),'Date Table'[Work Week]
)

Regards

BILASolution

Anonymous
Not applicable

Thank you both for your prompt help!! So @BILASolution's formula which used combo of COUNTX and SUMMARIZE works wonder for my case! The FILTER was used right after the SUMMARIZE function to clean the table right away before counting so that works perfect. I tried using COUNTROWS nested under CALCULATE to filter the ">20" part but didn't get too far. Thanks again!

 

                                             

Ashish_Mathur
Super User
Super User

Hi,

 

Try this

 

=IF(HASONEVALUE('Data Table'[Employee Name]),IF([Week OT]>20,1,0),CALCULATE(COUNTROWS('Data Table'),FILTER('Data table',[Week OT]>25)))

 

Does this work?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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