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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
acg
Resolver I
Resolver I

Create new table with max values - some issues

I need to transfer this calculation into a table as the dashboard has become too slow:

Overtime =
VAR currentEmpID = MAX ( 'Timesheet Data'[Employee ID])
VAR currentLDW = MAX ( 'Timesheet Data'[last_day_of_week])
VAR currentContractHours = MAX ( 'Timesheet Data'[Work_Week_Hours] )
VAR OT =
CALCULATE (
SUM ( 'Timesheet Data'[Hours] ),
FILTER (
ALL ( 'Timesheet Data'[Employee ID], 'Timesheet Data'[last_day_of_week] ),
'Timesheet Data'[Employee ID] = currentEmpID
&& 'Timesheet Data'[last_day_of_week] = currentLDW
)
) - currentContractHours
RETURN OT

 

THe way I planned to do it is to place the 3 VAr statements into a table:

VAR currentEmpID = MAX ( 'Timesheet Data'[Employee ID])
VAR currentLDW = MAX ( 'Timesheet Data'[last_day_of_week])
VAR currentContractHours = MAX ( 'Timesheet Data'[Work_Week_Hours] )

--------------------------------------------------------

And I am trying this:

 

 

Calculated_times =
SUMMARIZE(
ADDCOLUMNS(
'rep_timesheet_data',
"currentEmpID", CALCULATE (
MAX( rep_timesheet_data[Employee ID]),
FILTER (rep_timesheet_data, rep_timesheet_data[Employee ID] = "currentEmpID" )
),
"currentLDW", CALCULATE (
MAX ( rep_timesheet_data[last_day_of_week]),
FILTER (rep_timesheet_data, rep_timesheet_data[last_day_of_week] = "currentLDW" )
),
"OT", CALCULATE (
SUM( rep_timesheet_data[Work_Week_Hours]),
FILTER (rep_timesheet_data, rep_timesheet_data[Work_Week_Hours] = "OT" )
)
),
[currentEmpID],
[currentLDW],
[OT]
)
 
THe mistake I am getting is:
DAX comparison operations do not support comparing values of type Number with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values.
 
So [Employee ID] is a text format, while [last_day_of_week] is a date and [Work_Week_Hours] are decimals. 
Like the DAX  error message says, I could potentially add a format to Employee. Apart from not being sure where to place the FORMAT, I wonder whether I would not get issues along the lines when wanting to use the calculated variables with my main table? 
 
Is there a better way to create a new table with the above three variables?
 
2 REPLIES 2
amitchandak
Super User
Super User

@acg , what is the data type of Work_Week_Hours

at one place you are adding

at one place you are comparing Work_Week_Hours = "OT"

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

Hi amitchandax, Work_Week_Hours is decimal type. maybe create diferent tables for the MAX values and the SUM I hear you say?

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.