Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

How to SUM the rows in column X which are selected by a DISTINCT on column Y?

I have been stuck with this issue for a while now, I want to sum the Y column, but only on DISTINCT values of Column X. If I would filter in the report on tables(Table1 & Table2), I want the measure to calculate on the table that is selected.

 

I have tried the following statement, but it returns an error:

Z = DIVIDE(SUMX('myTable'[Y]);DISTINCT(myTable[Table])))
 
Error: 
A single value for column 'gewicht' in table '_dataerror' cannot be determined. 
This can happen when a measure formula refers to a column that contains many values without specifying
an aggregation such as min, max, count, or sum to get a single result.

Table structure myTable:

 

Table           X                    Y
Table1          supplier             2
Table1          customer             1
Table1          supplier             2
Table2          project              3
Table2          project              3
Table1          customer             1

The output that I am looking for here is a measure that does the following and returns one value:

 

If I would select Table 1:

3*2 + 2*1 / (2+1)

 

If I would select Table 2:

2*3 / 3

 

How can I get the values of column Y with using a distinct on column X ?

1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@Anonymous ,

 

You may try the measure below.

Measure =
SUMX ( VALUES ( myTable[X] ), CALCULATE ( MAX ( myTable[Y] ) ) )
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-chuncz-msft
Community Support
Community Support

@Anonymous ,

 

You may try the measure below.

Measure =
SUMX ( VALUES ( myTable[X] ), CALCULATE ( MAX ( myTable[Y] ) ) )
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.