Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi, I'm trying to get a columbn to SUM all the values for a given code, in every row that code is in. See below example
But the issue is my formula I'm using keeps giving just the SUM of the one row every time
Any help is much appreciated
Test = CALCULATE( SUM( Table[Value]), Table[Code] = Table[Code] )
| Code | Value | Actual Response | Required Response |
| A | 2 | 2 | 6 |
| A | 2 | 2 | 6 |
| A | 2 | 2 | 6 |
| B | 2 | 2 | 4 |
| B | 2 | 2 | 4 |
| C | 2 | 2 | 8 |
| C | 2 | 2 | 8 |
| C | 2 | 2 | 8 |
| C | 2 | 2 | 8 |
| D | 2 | 2 | 4 |
| D | 2 | 2 | 4 |
Solved! Go to Solution.
Here are a couple of additional alternatives:
Test =
VAR _Code = Table[Code]
RETURN
CALCULATE ( SUM ( Table[Value] ), Table[Code] = _Code )
Test =
CALCULATE ( SUM ( Table[Value] ), ALLEXCEPT ( Table, Table[Code] ) )
Here are a couple of additional alternatives:
Test =
VAR _Code = Table[Code]
RETURN
CALCULATE ( SUM ( Table[Value] ), Table[Code] = _Code )
Test =
CALCULATE ( SUM ( Table[Value] ), ALLEXCEPT ( Table, Table[Code] ) )
@DimaMD thanks - that works for some, but a lot of the codes are adding up as they go, so onlt the last code in the table has the full total - Is there a better function that EARLIER() ??
I got past this by adding another column that gives the MAX result. Ideally I'd like to avoid having 2 columns
hi @michaelmichael If you use this in the count column, try this code
CALCULATE(SUM('Лист1'[Value]),'Лист1'[Code] = EARLIER('Лист1'[Code]))
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 20 | |
| 11 | |
| 9 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 31 | |
| 29 | |
| 21 | |
| 12 | |
| 12 |