March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
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]) ?
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
23 | |
16 | |
12 | |
9 | |
7 |
User | Count |
---|---|
38 | |
32 | |
29 | |
12 | |
11 |