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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.