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
How to sum/summarize, by group and an IF:
| Data As Is | |||
| Product Name | Transaction ID | Jurisdiction Type | Gross Amount |
| P0001 | 123123 | STATE | 125.00 |
| P0001 | 123123 | COUNTY | 125.00 |
| P0001 | 123123 | CITY | 125.00 |
| P0001 | 123123 | STC | 125.00 |
| P0001 | 123123 | STATE | 125.00 |
| P0001 | 123123 | CITY | 125.00 |
| P0001 | 123123 | STATE | 25.00 |
| P0002 | 456456 | STATE | 10.00 |
P0002 | 456456 | CITY | 10.00 |
| P0002 | 456456 | STATE | 10.01 |
| P0003 | 456456 | STATE | 5.00 |
| P0004 | 789789 | STATE | 1.50 |
| P0004 | 789789 | STATE | 1.50 |
| Summary of what it should be | |||
| Product Name | Transaction ID | Product Name | Total Gross Amount |
| P0001 | 123123 | P0001 | 275.00 |
| P0002 | 456456 | Multiple/P0002/P0003 | 25.01 |
| P0004 | 789789 | P0004 | 3.00 |
Formula 1:
Solved! Go to Solution.
I think the issue is including [Gross Amount] in the grouping (rather than aggregating it with a SUM).
If you want to include duplicate rows for STATE but not other jurisdictions, try this:
Gross Sales =
VAR _Summary_ =
SUMMARIZE (
'Transactions',
'Transactions'[Product Name],
'Transactions'[Transaction ID],
'Transactions'[Jurisdiction Type],
"@SumAmount", SUM ( 'Transactions'[Gross Amount] ),
"@MaxAmount", MAX ( 'Transactions'[Gross Amount] )
)
RETURN
SUMX (
_Summary,
IF (
'Transactions'[Jurisdiction Type] = "STATE",
[@SumAmount],
[@MaxAmount]
)
)
If you always want to count duplicates (not just for STATE), then I think you just do a simple sum:
Gross Sales = SUM ( 'Transactions'[Gross Amount] )
I think the issue is including [Gross Amount] in the grouping (rather than aggregating it with a SUM).
If you want to include duplicate rows for STATE but not other jurisdictions, try this:
Gross Sales =
VAR _Summary_ =
SUMMARIZE (
'Transactions',
'Transactions'[Product Name],
'Transactions'[Transaction ID],
'Transactions'[Jurisdiction Type],
"@SumAmount", SUM ( 'Transactions'[Gross Amount] ),
"@MaxAmount", MAX ( 'Transactions'[Gross Amount] )
)
RETURN
SUMX (
_Summary,
IF (
'Transactions'[Jurisdiction Type] = "STATE",
[@SumAmount],
[@MaxAmount]
)
)
If you always want to count duplicates (not just for STATE), then I think you just do a simple sum:
Gross Sales = SUM ( 'Transactions'[Gross Amount] )
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 | |
| 10 | |
| 9 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 34 | |
| 31 | |
| 19 | |
| 12 | |
| 10 |