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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Richard_Halsall
Helper IV
Helper IV

TREATAS not displaying all values in a matrix

Hi

I am struggling to write the correct DAX for the following:

 

I have a disconnected table titled Peak Headcount with the format as follows

TechBucketTechGoalDivision
Blade Tech 4 Contractors67US
Blade Tech 3 Contractors80US
Blade Tech 1/2 Employees34US

 

I have a table named DimContractors containing a Primary Role (naming equivalent to TechBucket) which for information I have summarised for reference as below:

Richard_Halsall_0-1713448255058.png

 

I am creating this matrix

Richard_Halsall_1-1713448339691.png

Which shows values against the Peak Headcount column showing zero  for 3 roles even though they exist in the Peak Headcount table
These are the measures I am using to calculate the Peak Headcount column

Peak Headcount =
VAR Division = SELECTEDVALUE('FactSupply'[ContractType])
VAR US = [Peak Headcount Technician US]
RETURN
IF(CONTAINSSTRING(Division,"US"), US,0)



Peak Headcount Technician US =
CALCULATE(MIN('Peak Headcount'[TechGoal]),
TREATAS(VALUES('DimContractor'[PrimaryRole]), 'Peak Headcount'[TechBucket]),
 'Peak Headcount'[Division] = "US")

 

Any advice would be appreciated. Thanks

2 REPLIES 2
tamerj1
Super User
Super User

Hi @Richard_Halsall 
I have so many doubts but that is probably because I couldn't see the full picture. However, I'm also suspicious about:
VAR Division = SELECTEDVALUE 'FactSupply'[ContractType] ) that it probably produces a blank due to more than one value existing in the filter context. Again I'm in the dark here, I don't see what you see but this is just a guess. You may try:

 

Peak Headcount =
SUMX (
    VALUES ( 'FactSupply'[ContractType] ),
    VAR Division = 'FactSupply'[ContractType]
    VAR US = [Peak Headcount Technician US]
    RETURN
        IF ( CONTAINSSTRING ( Division, "US" ), US, 0 )
)

 

Hi, thanks for the quick response and I believe it has highlighted what the issue is but I still do not how to fix it.

 

It is the VAR Division = SELECTEDVALUE 'FactSupply'[ContractType] ) which you corrected to 

VAR Division = 'FactSupply'[ContractType]


FactSupply[ContractType] is used in a slicer visual (called 'Text Search Slicer') and the ContractType field contains
US
AU/US
UK/US

hence I was using CONTAINSSTRING as I just want those people with US in that field

Now the values with your corrected measure that are still incorrect appear to be mulitplying if for that role there is a ContractType of US, AU/US and UK/US

Those that are correct only have a ContractType of US

Are you able to assist further. Thanks



Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.