Forum Discussion
Matching Totals Once Using Filters
- 2 years ago
Thank you all - for now I have gone with ...
This is because SUMX did not want to work and repeated the same number all the way down however I will go back but assume I could get a couple of missed numbers for now.
Sum Project Billed Milestones = CALCULATE( SUM(Autotask_ContractMilestones_Billed[amount]), FILTER( DISTINCT(Autotask_ContractMilestones_Billed[contractID]), Autotask_ContractMilestones_Billed[contractID] = Autotask_Projects[contractID] ) )I will also have a look at the schema option which seems to be a good way forward too.
Thanks
T
To achieve the desired result of showing the total only once for each unique match, you can use the DISTINCT function in DAX. This function ensures that only distinct values are considered in the calculation. Here's how you can modify your DAX measure:
Sum Project Not Billed Milestones =
CALCULATE(
SUMX(
DISTINCT(AT_Projects[contractID]),
CALCULATE(
SUM(AT_ContractMilestones_NotBilled[amount]),
FILTER(
AT_ContractMilestones_NotBilled,
AT_ContractMilestones_NotBilled[contractID] = AT_Projects[contractID]
)
)
)
)
In this measure:
- SUMX iterates over each distinct contractID in the AT_Projects table.
- DISTINCT function ensures that each contractID is considered only once.
- CALCULATE is used to perform the filtering and calculation for each distinct contractID.
- FILTER is applied to filter the AT_ContractMilestones_NotBilled table based on the current contractID being iterated.
- SUM calculates the sum of the filtered amount for each contractID.
This way, the total should only be shown once for each unique match, ensuring the correctness of the total at the bottom.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.