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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
SBC
Helper III
Helper III

Matrix subtotal showing incorrect totals when using TREATAS() to map Allocation Units per employee

Hi,

I am working on a Power BI matrix visual where I need to display Allocation Units per employee and also show correct subtotals at the department level and grand total level.

Matrix Structure

Rows:

  • DepartmentName

  • EmployeeName

Values:

  • Allocation Units (measure)

Tables Used

Table 1: Activity_Log_Table
Contains:

  • DepartmentName

  • EmployeeName

Table 2: Resource_Allocation_Table
Contains:

  • StaffFullName

  • AllocationUnits

There is no direct relationship between these tables, so I am using TREATAS() to map EmployeeName with StaffFullName.

Current Measure

Allocation Units Measure =
CALCULATE(
MAX('Resource_Allocation_Table'[AllocationUnits]),
TREATAS(
VALUES('Activity_Log_Table'[EmployeeName]),
'Resource_Allocation_Table'[StaffFullName]
)
)

Problem

The measure returns correct values at the EmployeeName level, but:

  • DepartmentName subtotal is incorrect

  • Grand total is incorrect

  • Power BI recalculates totals instead of summing visible rows

Expected Behaviour

I want the matrix totals to behave like Excel-style aggregation:

  • Show correct allocation units per EmployeeName

  • Show subtotal per DepartmentName as sum of EmployeeName values

  • Show correct grand total as sum of all EmployeeName values

  • Avoid duplicate counting when EmployeeName appears multiple times

Sample Data

Activity_Log_Table

 

DepartmentNameEmployeeName
OrionAlex M
OrionNina P
OrionKevin L
NovaDaniel R
NovaSophia T

 

Resource_Allocation_Table:

 

StaffFullNameAllocationUnits
Alex M40
Nina P25
Kevin L15
Daniel R35
Sophia T20

 

Expected Matrix Output

  

DepartmentNameEmployeeNameAllocation Units
OrionAlex M40
OrionNina P25
OrionKevin L15
Orion Total 80
NovaDaniel R35
NovaSophia T20
Nova Total 55
Grand Total 135

Currently, subtotals and grand totals are not matching the expected summed values.

What is the correct DAX approach to ensure totals aggregate properly when using TREATAS() inside a matrix visual?

 

Thanks,

SBC

1 ACCEPTED SOLUTION
SBC
Helper III
Helper III

Thanks Everyone, I was able to resolve the issue by modifying the measure so that totals are calculated using an explicit row-level aggregation instead of relying on the default evaluation context inside the matrix visual.

The problem occurred because the matrix subtotal and grand total were being recalculated rather than summing the visible employee-level values when using TREATAS().

Below is the working solution:

Allocation Units Measure =
SUMX(
SUMMARIZE(
CALCULATETABLE(
'Resource_Allocation_Table',
TREATAS(
VALUES('Activity_Log_Table'[EmployeeName]),
'Resource_Allocation_Table'[StaffFullName]
)
),
'Resource_Allocation_Table'[StaffFullName],
'Resource_Allocation_Table'[AllocationUnits]
),
'Resource_Allocation_Table'[AllocationUnits]
)

After applying this logic, both department-level subtotals and the overall total are now aggregating correctly in the matrix visual.

Sharing this here in case it helps others facing similar subtotal issues when using TREATAS().

 

 

Thanks,

SBC

 

View solution in original post

3 REPLIES 3
Ray_Minds
Solution Supplier
Solution Supplier

Solution: This error is usually not related to DAX or report logic -
it’s a temporary Power BI Service issue. It can happen due to session timeout, dataset connectivity issues, or sometimes just a backend glitch.
Quick things to try:
* Refresh the page or open in Incognito.
* Logout and login again.
* Try a different browser.
If it still doesn’t work, then check:
* Dataset refresh / credentials
* Workspace access or permissions
If the issue continues, share the Exception ID with your admin - they can trace it from backend logs.

Kedar_Pande
Super User
Super User

@SBC 

 

Fixed measure

Allocation Units = 
SUMX(
VALUES('Activity_Log_Table'[EmployeeName]),
CALCULATE(
MAX('Resource_Allocation_Table'[AllocationUnits]),
TREATAS(
'Activity_Log_Table'[EmployeeName],
'Resource_Allocation_Table'[StaffFullName]
)
)
)

Test it - subtotals match expected exactly

SBC
Helper III
Helper III

Thanks Everyone, I was able to resolve the issue by modifying the measure so that totals are calculated using an explicit row-level aggregation instead of relying on the default evaluation context inside the matrix visual.

The problem occurred because the matrix subtotal and grand total were being recalculated rather than summing the visible employee-level values when using TREATAS().

Below is the working solution:

Allocation Units Measure =
SUMX(
SUMMARIZE(
CALCULATETABLE(
'Resource_Allocation_Table',
TREATAS(
VALUES('Activity_Log_Table'[EmployeeName]),
'Resource_Allocation_Table'[StaffFullName]
)
),
'Resource_Allocation_Table'[StaffFullName],
'Resource_Allocation_Table'[AllocationUnits]
),
'Resource_Allocation_Table'[AllocationUnits]
)

After applying this logic, both department-level subtotals and the overall total are now aggregating correctly in the matrix visual.

Sharing this here in case it helps others facing similar subtotal issues when using TREATAS().

 

 

Thanks,

SBC

 

Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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