Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
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
TechBucket | TechGoal | Division |
Blade Tech 4 Contractors | 67 | US |
Blade Tech 3 Contractors | 80 | US |
Blade Tech 1/2 Employees | 34 | US |
I have a table named DimContractors containing a Primary Role (naming equivalent to TechBucket) which for information I have summarised for reference as below:
I am creating this matrix
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
Any advice would be appreciated. Thanks
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
User | Count |
---|---|
57 | |
22 | |
21 | |
19 | |
16 |
User | Count |
---|---|
86 | |
84 | |
52 | |
37 | |
23 |