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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Richard_Halsall
Helper III
Helper III

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors