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 have a big model in PowerBI where there are many different aggregation and grouping based on columns being displayed or not on the final table.
Simplifying: I need to do a conditional statement doing the sum if the value of column 1 is A1 but doing the MAX() if the value of column 1 is A2.
I need to have that information in the same colum of the final output. How would you go for this one?
Thank you very much for your help!
Solved! Go to Solution.
To obtain correct total you can may try
Measur =
SUMX (
VALUES ( 'Table'[Column1] ),
CALCULATE (
IF (
'Table'[Column1] = "A",
SUM ( 'Table'[Column2] ),
MAX ( 'Table'[Column2] )
)
)
)
Hi @fosterXO ,
Please have a try.
Create a measure.
Measure =
SWITCH (
TRUE (),
MAX ( 'Table'[Column1] ) = "A1",
SUMX (
FILTER (
ALL ( 'Table' ),
'Table'[Column1] = SELECTEDVALUE ( 'Table'[Column1] )
),
'Table'[Column2]
),
MAX ( 'Table'[Column1] ) = "A2",
MAXX (
FILTER (
ALL ( 'Table' ),
'Table'[Column1] = SELECTEDVALUE ( 'Table'[Column1] )
),
'Table'[Column2]
),
BLANK ()
)
If I have misunderstood your meaing, please provide more details.
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @fosterXO ,
Please have a try.
Create a measure.
Measure =
SWITCH (
TRUE (),
MAX ( 'Table'[Column1] ) = "A1",
SUMX (
FILTER (
ALL ( 'Table' ),
'Table'[Column1] = SELECTEDVALUE ( 'Table'[Column1] )
),
'Table'[Column2]
),
MAX ( 'Table'[Column1] ) = "A2",
MAXX (
FILTER (
ALL ( 'Table' ),
'Table'[Column1] = SELECTEDVALUE ( 'Table'[Column1] )
),
'Table'[Column2]
),
BLANK ()
)
If I have misunderstood your meaing, please provide more details.
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
To obtain correct total you can may try
Measur =
SUMX (
VALUES ( 'Table'[Column1] ),
CALCULATE (
IF (
'Table'[Column1] = "A",
SUM ( 'Table'[Column2] ),
MAX ( 'Table'[Column2] )
)
)
)
Hi @fosterXO
I agree with @Anonymous . But the result would be in a separate column. Power BI would not let you show this data in the same column.
Hi
If(selectedvalue(Column1)="A1",sum(column2),Max (Column2))
if you have more choice of column1 values make the if statement each time
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 |
|---|---|
| 33 | |
| 31 | |
| 19 | |
| 12 | |
| 11 |