Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Bansi008
Helper III
Helper III

Required help in conditional SUM function using DAX query.

Hi there,

I have given sample table for reference, using SEC_ISSUER as identifier I need to calculate sum of total value using VALUE column

for example, DAX query should sum up for all sec_name values where corrosponding sec_issuer identier found. 

TOTAL_VALUE is expected result. 

SEC_NAMESEC_ISSUERVALUETOTAL_VALUE
ABCAB110
ABCDAB210
ABCDEAB310
ABCEDFAB410
OPQOP518
OPQROP618
OPQRSOP718

 

1 ACCEPTED SOLUTION
Ritaf1983
Super User
Super User

Hi @Bansi008 
You can use the measure :

sum_by_issuer = CALCULATE(
    sum('Table'[VALUE]),ALLEXCEPT('Table','Table'[SEC_ISSUER]))
Ritaf1983_0-1720790012598.png

The pbix is attached

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

3 REPLIES 3
Bansi008
Helper III
Helper III

Thanks @Ritaf1983 , this worked. I need one more help regarding the same query. Can we amend this syntax where I other issuer total value stay as it is but only purchase value will be in reverse sign. Example if sum of purchase value based on issuer is -100 then it should populate as 100 or vise versa. Rest everything should stay as it is.

DATESEC_NAMESEC_ISSUERVALUETYPETOTAL_VALUE
6/30/2023ABCAB-1Purchase4
7/31/2023ABCDAB2Expense2
8/31/2023ABCDEAB-3Purchase4
9/30/2023ABCEDFAB4Sale4
10/31/2023OPQOP5Income5
11/30/2023OPQROP6Sale6
12/31/2023OPQRSOP-7Purchase7

Hi @Bansi008 
If I understood you correctly, the measure for fixed value will be :

Fixed value =
if(max('Table'[Type])="purchase" , sum('Table'[VALUE])*-1,
sum('Table'[VALUE]))
Ritaf1983_0-1720852240364.png

And the previous measure will change to :

sum_by_issuer =
VAR
Table_=CALCULATETABLE('Table',ALLEXCEPT('Table','Table'[SEC_ISSUER]))
RETURN
SUMX(Table_,[Fixed value])
Ritaf1983_1-1720852294381.png

The updated PBIX is attached

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
Ritaf1983
Super User
Super User

Hi @Bansi008 
You can use the measure :

sum_by_issuer = CALCULATE(
    sum('Table'[VALUE]),ALLEXCEPT('Table','Table'[SEC_ISSUER]))
Ritaf1983_0-1720790012598.png

The pbix is attached

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.