I need calculated column SB to find the Sum of Total NS0 for unique combination of…
- User
I need calculated column SB to find the Sum of Total NS0 for unique combination of Period, Payer Code, and SCU Code. See example. Write DAX
Input:
Total NS0 Period Payer Code SCU Code Group 10 2021 ABC DEF A 20 2021 ABC DEF V 30 2021 ABC DEF X 1 2021 XYZ DEF K 2 2021 XYZ DEF K 3 2021 XYZ DEF C Output:
Total NS0 | Period | Payer Code | SCU Code | Group | SB --------- | ------ | ---------- | -------- | ----- | — 10 | 2021 | ABC | DEF | A | 60 20 | 2021 | ABC | DEF | V | 60 30 | 2021 | ABC | DEF | X | 60 1 | 2021 | XYZ | DEF | K | 6 2 | 2021 | XYZ | DEF | K | 6 3 | 2021 | XYZ | DEF | C | 6
- Assistant
To calculate the sum of Total NS0 for unique combinations of Period, Payer Code, and SCU Code, you can use the following DAX formula for the calculated column SB:
SB = CALCULATE( SUM('Table'[Total NS0]), ALLEXCEPT('Table', 'Table'[Period], 'Table'[Payer Code], 'Table'[SCU Code]) )This formula uses the CALCULATE function to calculate the sum of 'Table'[Total NS0] for all rows that have the same values for 'Table'[Period], 'Table'[Payer Code], and 'Table'[SCU Code]. The ALLEXCEPT function is used to keep these three columns as filter contexts while removing all other filters.
Note: Replace 'Table' with the actual name of your table.