Forum Discussion
SUM for 2 tables
- 6 years ago
hi TSI
try this
Total Headcount = sumx('Country Main';'Country Main'[Headcount]) + lookupvalue('Country A Monthly'[Headcount];'Country A Monthly'[Month];selectedvalue('Country Main'[Month]);'Country A Monthly'[Country];SELECTEDVALUE('Country Main'[Country]) )But, it won't calulate total of 'Total Headcount' correctly
in my opinion, for your data model would be better to create key columns in both tables, like this for 'Country Main'
ColumnKey = concatenate('Country Main'[Country];'Country Main'[Month])and for 'Country A Monthly'
ColumnKey = concatenate('Country A Monthly'[Country];'Country A Monthly'[Month])then create one-to-one relationships between tables via ColumnKey
and then in Country Main table create new column
Column = 'Country Main'[Headcount]+related('Country A Monthly'[Headcount])do not hesitate to kudo useful posts and mark solutions as solution
Linkedin
hi TSI
try this
Total Headcount = sumx('Country Main';'Country Main'[Headcount]) +
lookupvalue('Country A Monthly'[Headcount];'Country A Monthly'[Month];selectedvalue('Country Main'[Month]);'Country A Monthly'[Country];SELECTEDVALUE('Country Main'[Country])
)
But, it won't calulate total of 'Total Headcount' correctly
in my opinion, for your data model would be better to create key columns in both tables, like this for 'Country Main'
ColumnKey = concatenate('Country Main'[Country];'Country Main'[Month])
and for 'Country A Monthly'
ColumnKey = concatenate('Country A Monthly'[Country];'Country A Monthly'[Month])
then create one-to-one relationships between tables via ColumnKey
and then in Country Main table create new column
Column = 'Country Main'[Headcount]+related('Country A Monthly'[Headcount])
do not hesitate to kudo useful posts and mark solutions as solution
Linkedin
Hi az38 ,
The sum by Market worked!
The extra solution you gave of creating a key column in both tables is brilliant - you went the extra mile after noticing that the Total didn't add up correctly even when sum by Market did. Being new to DAX, I really appreciated the detailed steps and clear explanation.
Thank you so much for your help.