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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Sarahparker2
Frequent Visitor

Can sum negaitive values

I have a list of account balances both positive and negaitive. The account balance is calculated using a measure, i then would like to sum only the negative values and display by account type. When i do this it will only display the negative balances if the sum of the every account in the account type is negative instead of displaying the sum of all the negative values within each account type.

 

Can any one please advise.

1 ACCEPTED SOLUTION
v-sihou-msft
Employee
Employee

@Sarahparker2

 

In this scenario, to sum the negative values, you just need to filter those negative rows in your calculation. Please refer to my sample below:

 

 

 

1. Create Total measure group on Type:

Total = CALCULATE(SUM(Table1[Value]),ALLEXCEPT(Table1,Table1[Type]))

2. Create Negative Total measure:

 

Negative Total = CALCULATE(SUM(Table1[Value]),FILTER(Table1,Table1[Value]<0),ALLEXCEPT(Table1,Table1[Type]))

3. Create the conditional Total as you required:

 

Conditional Total = IF([Total]<0,[Negative Total],[Total])

The result looks like below:

 

55.PNG

 

Regards,

View solution in original post

3 REPLIES 3
v-sihou-msft
Employee
Employee

@Sarahparker2

 

In this scenario, to sum the negative values, you just need to filter those negative rows in your calculation. Please refer to my sample below:

 

 

 

1. Create Total measure group on Type:

Total = CALCULATE(SUM(Table1[Value]),ALLEXCEPT(Table1,Table1[Type]))

2. Create Negative Total measure:

 

Negative Total = CALCULATE(SUM(Table1[Value]),FILTER(Table1,Table1[Value]<0),ALLEXCEPT(Table1,Table1[Type]))

3. Create the conditional Total as you required:

 

Conditional Total = IF([Total]<0,[Negative Total],[Total])

The result looks like below:

 

55.PNG

 

Regards,

Hi,

 

Just to confirm SUM presented by "Conditional Total" will not work in this case as its measure correct ? I wanted to display conditional total from only those measures whose value is positive.

 

 

Regards

 

Digant

Thank you, this worked perfectly.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.