Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Dear community, I am looking for a way to calculate sum of a column ("Value" colume in the table shown below). Appreciate any help you can provide. Thanks.
Category 1 | Value | |
50 | ||
40 | ||
A | 30 | |
A | 30 | |
B | 20 | |
C | 10 | |
C | 10 | |
Expected result | 50+40+30+20+10 | 150 |
Solved! Go to Solution.
@qianqianat007
Please refer to attached sample file
Sum =
SUMX (
VALUES ( 'Table'[Category] ),
IF (
'Table'[Category] = BLANK (),
SUMX ( CALCULATETABLE ( 'Table' ), 'Table'[Value] ),
SUMX ( CALCULATETABLE ( VALUES ( 'Table'[Value] ) ), 'Table'[Value] )
)
)
please try
Sum =
SUMX (
VALUES ( 'Table'[Category] ),
IF (
'Table'[Category] = BLANK (),
SUMX ( CALCULATETABLE ( 'Table' ), 'Table'[Value] ),
SUMX ( CALCULATETABLE ( VALUES ( 'Table'[Value] ) ), 'Table'[Value] )
)
)
Dear @tamerj1 thanks for sharing your idea! I tried it and get 240 as result (expect 200).
Dear @tamerj1 I tried your this code and got 240 as result (expect 200).
Sum =
SUMX (
VALUES ( 'Table'[Category] ),
IF (
'Table'[Category] = BLANK (),
SUMX ( CALCULATETABLE ( 'Table' ), 'Table'[Value] ),
SUMX ( CALCULATETABLE ( VALUES ( 'Table'[Value] ) ), 'Table'[Value] )
)
)
@qianqianat007
Please refer to attached sample file
Sum =
SUMX (
VALUES ( 'Table'[Category] ),
IF (
'Table'[Category] = BLANK (),
SUMX ( CALCULATETABLE ( 'Table' ), 'Table'[Value] ),
SUMX ( CALCULATETABLE ( VALUES ( 'Table'[Value] ) ), 'Table'[Value] )
)
)
Dear community, I am looking for a way to calculate sum of a column ("Value" colume in the table shown below). Appreciate any help you can provide. Thanks.
Category 1 | Value | |
50 | ||
40 | ||
A | 30 | |
A | 30 | |
B | 20 | |
C | 10 | |
C | 10 | |
Expected result: 50+40+30+20+10=150 |
@Greg_DecklerIt works very well for this data sample, thank you! But in my real data, empty category rows can sometimes have same value (see below, expected result is 200). Any idea how can I solve this?
Category | Value |
50 | |
40 | |
50 | |
A | 30 |
A | 30 |
B | 20 |
C | 10 |
C | 10 |
@qianqianat007 I'm not quite clear as to the logic of what is supposed to be summed and what is not supposed to be summed. What is supposed to be summed in this latest example in order to get you to 200?
Dear @Greg_Deckler, in the latest example, for rows where Category is empty (row 1, 2, 3), each Value should be counted (50 + 50 + 40); for rows where Category is not empty (row 5 to 9), only distinct value should be counted (30 + 20 + 10). Hope that's clear now.. Thanks!
Category | Value | |||
50 | ||||
50 | ||||
40 | ||||
A | 30 | |||
A | 30 | |||
B | 20 | |||
C | 10 | |||
C | 10 | |||
expected result: 50 + 50 + 40 + 30 + 20 + 10 = 200 |
a small correction: row 5 to 9 --> row 4 to 8
@qianqianat007 Maybe something like SUMX(DISTINCT('Table'[Value]), [Value]) ?
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
20 | |
7 | |
6 | |
5 | |
5 |
User | Count |
---|---|
26 | |
10 | |
10 | |
9 | |
6 |