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.
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 July 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
7 | |
7 | |
6 | |
6 |
User | Count |
---|---|
27 | |
12 | |
10 | |
9 | |
6 |