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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

GroupBY with a constant value

I have a timesheet export that contains columns with the date, acitivity and hours worked:

JWSouthAfrica_1-1633332905873.png

I wrote the following DAX GroupBy formula to group hours per day, which gives the desired result of total hours per date:

DateHours =
GROUPBY(
Sheet1,
Sheet1[Date],
"SumHours", SUMX(CURRENTGROUP(), Sheet1[Hours])
)

 

I want to add a line to this that calculates the amount of overtime based on an 8 hours day:
DateHours =

GROUPBY(
Sheet1,
Sheet1[Date],
"SumHours", SUMX(CURRENTGROUP(), Sheet1[Hours]),
"Overtime", SUMX(CURRENTGROUP(), Sheet1[Hours])-8)

)

 

This however gives me an error:

"Function 'GROUPBY' scalar expressions have to be Aggregation functions over CurrentGroup(). The expression of each Aggregation has to be either a constant or directly reference the columns in CurrentGroup()."

 

My question is how do I add a SUMX plus constant value and calculation in this calulated table to get the overtime hours worked per date?

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , You can create a new column

 

Overtime = Sheet1[Hours])-8

 

or new measure and use that in visual

"Overtime", SUMX(values(Sheet[Date]), Sheet1[Hours])-8)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thanks, creating a new column worked!

amitchandak
Super User
Super User

@Anonymous , You can create a new column

 

Overtime = Sheet1[Hours])-8

 

or new measure and use that in visual

"Overtime", SUMX(values(Sheet[Date]), Sheet1[Hours])-8)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.