Calculated Member for SUM of distinct values by dimension

Lane Meadows 5 Reputation points
2023-10-27T15:58:42.3466667+00:00

I have a multidimensional cube in SSAS. My fact table looks like this with a reference to a dimension, a column for a value, and a column for the amount.

DimMember | TheValue | Amount

1 | 10 | 100

1 | 10 | 300

1 | 10 | 200

2 | 30 | 500

2 | 30 | 100

3 | 10 | 300

       |       50 |    1500

 

I want to create a calculated member in the cube that will sum up TheValue rows but only once per dimension. The Amount column should sum every row normally, but TheValue column needs to be the sum of one instance per dimension. So TheValue column should sum up to 50 in this example. 10 + 30 + 10, not the sum of every row.

I have seen examples of answers for DISTINCT values for the column, but that will not work in this case because the values do not have to be unique across the dimension members.

Any help is appreciated.

SQL Server Analysis Services
SQL Server Analysis Services
A Microsoft online analytical data engine used in decision support and business analytics, providing the analytical data for business reports and client applications such as Power BI, Excel, Reporting Services reports, and other data visualization tools.
1,247 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Alexei Stoyanovsky 3,416 Reputation points
    2023-10-27T22:11:18.4233333+00:00

    You should be able to pull this off directly with two helper physical measures, one a sum of TheValue, the other a count, and with a calculation of sum(existing dim, divide(SumValue,CountValue)). A better solution would be to create a derivative fact table as distinct DimMember, TheValue and use it as a source of another measure group, where the measure would be a straightforward sum.