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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
lovishsood1
Resolver I
Resolver I

Fix DAX for Calculate cross tables

Hi guys,

 

Here is my DAX Query, for which I have trouble finding the solution.

Sometimes it gives an error on the Leaves table or sometimes random errors anywhere.

 

EVALUATE CALCULATETABLE( SUMMARIZECOLUMNS( Employees[EmployeeCode], Employees[FullName], DateTable[FormatDate], DateTable[Day Name], "In Time", MIN(PunchInRecords[In_Time]), /*Measure*/ "Out Time", MAX(PunchInRecords[Out_Time]), /*Measure*/ "Punch-In Hours", SUM(PunchInRecords[PunchInHours]), /*Measure*/ "Break Hours", SUM(PunchInRecords[BreakHours]), /*Measure*/ "Work Hours", SUM(PunchInRecords[WorkHours]), /*Measure*/ "Leave Count", SUM(Leaves[LeaveCount]), /*Text Column*/ "Leave Type", CONCATENATEX(VALUES(Leaves[LeaveType]), Leaves[LeaveType], ";"), /*Text Column*/ "Leave Status", CONCATENATEX(VALUES(Leaves[RequestStatus]), Leaves[RequestStatus], ";"), /*Text Column*/ "WFH", SUM(WFH[WFH Count]), /*Text Column*/ "WFH Status", CONCATENATEX(VALUES(WFH[WFH Status]), WFH[WFH Status], ";"), /*Text Column*/ "OT", SUM(Overtime[OT_Count]), "Grant Type", CONCATENATEX(VALUES(Overtime[OT Redeem Type]), Overtime[OT Redeem Type], ";"), /*Text Column*/ "OT Status", CONCATENATEX(VALUES(Overtime[RequestStatus]), Overtime[RequestStatus], ";"), /*Text Column*/ "Color_Condition", MAX(PunchInRecords[newColor_Condition]) /*Measure*/ ), {filter_block} ) ORDER BY {order_column} {sort_dir}

 

Can anybody help me here?

1 ACCEPTED SOLUTION
lovishsood1
Resolver I
Resolver I

Hi All,

 

This has been resolved. It was just some data type issues and syntax errors on Table/Column Names.

This DAX is working fine.

View solution in original post

4 REPLIES 4
lovishsood1
Resolver I
Resolver I

Hi All,

 

This has been resolved. It was just some data type issues and syntax errors on Table/Column Names.

This DAX is working fine.

v-sshirivolu
Community Support
Community Support

Hi @lovishsood1 ,
Thanks for the update. I’ve reviewed the logic and here is the version of the new table DAX. This version uses a CROSSJOIN between Employees and DateTable, and then adds the daily values from each activity table. It now returns the expected results for each employee and date.

Base_Output =
VAR BaseTable =
SUMMARIZE(
CROSSJOIN( Employees, DateTable ),
Employees[EmployeeCode],
Employees[FullName],
DateTable[FormatDate],
DateTable[Day Name]
)
RETURN
ADDCOLUMNS(
BaseTable,
"In Time", CALCULATE( MIN( PunchInRecords[In_Time] ) ),
"Out Time", CALCULATE( MAX( PunchOutRecords[Out_Time] ) ),
"Punch Hours",
COALESCE(
CALCULATE( SUM( TimeRecords[TotalHours] ) ),
DIVIDE(
DATEDIFF(
CALCULATE( MIN( PunchInRecords[In_Time] ) ),
CALCULATE( MAX( PunchOutRecords[Out_Time] ) ),
MINUTE
),
60
)
),
"Break Hours", CALCULATE( SUM( BreakRecords[BreakHours] ) ),
"Leave Count",
CALCULATE(
COUNTROWS(
FILTER(
'Leaves',
'Leaves'[EmployeeCode] = SELECTEDVALUE( Employees[EmployeeCode] )
&& 'Leaves'[FormatDate] = SELECTEDVALUE( DateTable[FormatDate] )
)
)
),
"Total Hours", CALCULATE( SUM( TimeRecords[TotalHours] ) )
)

Let me know if you want any help further.

Thank you.
Praful_Potphode
Super User
Super User

Hi @lovishsood1 ,

usually functions like CONCATENATEX,ALL,SUMMARIZECOLUMNS,ALL,ALLEXCEPT,ALLSELECTED cause issues.my suggestion is to investigate them separately.try commenting one measures at a time to isolate the measure causing the real issue.

Please Give kudos or mark it as solution once confirmed.

 

Thanks and Regards,

Praful

 

Thanks and Regards,
Praful Potphode
LinkedIn-https://www.linkedin.com/in/praful-p-912349241/
ValtteriN
Community Champion
Community Champion

Hi, 

It is adds a bit of difficulty that there is no example data, no example errors and the dax is not formatted well. However, based on your description my first recommendation is that you check that the refecend tables have valid relationships to Employees and DateTable. Another suggestion is to SUMMARIZE + ADDCOLUMNS. Here is an example generated with copilot:

EVALUATE
VAR BaseTable =
    SUMMARIZE(
        Employees,
        Employees[EmployeeCode],
        Employees[FullName],
        DateTable[FormatDate],
        DateTable[Day Name]
    )
RETURN
ADDCOLUMNS(
    BaseTable,
    "In Time", CALCULATE(MIN(PunchInRecords[In_Time])),
    "Out Time", CALCULATE(MAX(PunchInRecords[Out_Time])),
    "Punch-In Hours", CALCULATE(SUM(PunchInRecords[PunchInHours])),
    "Break Hours", CALCULATE(SUM(PunchInRecords[BreakHours])),
    "Work Hours", CALCULATE(SUM(PunchInRecords[WorkHours])),
    "Leave Count", CALCULATE(SUM(Leaves[LeaveCount])),
    "Leave Type", CALCULATE(CONCATENATEX(VALUES(Leaves[LeaveType]), Leaves[LeaveType], ";")),
    "Leave Status", CALCULATE(CONCATENATEX(VALUES(Leaves[RequestStatus]), Leaves[RequestStatus], ";")),
    "WFH", CALCULATE(SUM(WFH[WFH Count])),
    "WFH Status", CALCULATE(CONCATENATEX(VALUES(WFH[WFH Status]), WFH[WFH Status], ";")),
    "OT", CALCULATE(SUM(Overtime[OT_Count])),
    "Grant Type", CALCULATE(CONCATENATEX(VALUES(Overtime[OT Redeem Type]), Overtime[OT Redeem Type], ";")),
    "OT Status", CALCULATE(CONCATENATEX(VALUES(Overtime[RequestStatus]), Overtime[RequestStatus], ";")),
    "Color_Condition", CALCULATE(MAX(PunchInRecords[newColor_Condition]))
)

If you need further help, please add example errors and mock data.

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/ 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.