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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
RoyB1973
New Member

Eleminate negative numbers in total from calculation

Hi All,

I'm trying to make a measure which eleminates the negative numbers.

 

Case:

3 datasets:

PMExtraTech which contains articles and the quantity.

PMAbonne which contains info about the end customer

Customer which contact info about our customers

 

For a special promotion our customers can earn points for gifts. Therefore I need to see how many growth a customer has between two periods.  The current period is updated every 2 hours with the latest information.

 

So I made a calculation which gives me the growth. When I make a table with the information, The first colomn is the CustomerId the Second one the growth and the third the earnt points. However you can't earn negative points. Untill sofar it works fine.

 

Growth.png

 

So 10 points per 1 qty. But you see that the total in both columns are the same. So in the total the negative numbers are also calculated? But they are not shown in the points column.

 

Relations:

PMExtraTech has and Connection with PMAbonnee

and PMAbonnee has a Connection with Customer

 

Used Calculation for the points:

 

RoyB1973_1-1639128327180.png

 

If have also tried a SumX with a Summarize on customer, but this is giving a more mixed up info.

 

When I removed the customer column and just changed the ( IF(CalCulation)<0,1,2) Then its gving a 2 as responce, so I think that is the reason why you don't see the negative numbers on customer, but they are counted in the total.

But I have no clue how to solve this on.

 

Who can help me.?

 

Greets RoyB

2 ACCEPTED SOLUTIONS
v-xiaotang
Community Support
Community Support

Hi @RoyB1973 

I create a sample, the sample not having your data, but the logic is relatively simple, 

In this sample, create a measure to calculate the sum, then judge whether it is greater than 0.

sum =
MIN ( 'Table'[Aantal1] ) + MIN ( 'Table'[Aantal2] )
Points =
VAR _a =
    IF ( [sum] < 0, 0, [sum] )
VAR _b =
    SUMX ( ALL ( 'Table' ), ABS ( [sum] ) )
RETURN
    IF ( ISINSCOPE ( 'Table'[Aantal1] ), _a, _b )

 

 

Then sum its absolute values.

The principe of the dax code is:

   for the 1st row: -2-1= -3 <0, then Points = 0, abs value = abs(-3) = 3,

   for the 2nd row:-1+2= 1 >0, then Points = 1, abs value = abs(1) = 1,

......

So the Total row = 3+1+2+1+1=8

vxiaotang_0-1640332117296.png

So you can try to put the part bellow into a measure, then judge the measure whether it is greater than 0.

vxiaotang_1-1639467323934.png

If you need more help, please let me know. And please provide the sample file or some sample data, so that I can recreate the same pbix file.

 

Best Regards,

Community Support Team _Tang

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

View solution in original post

Thanks, I managed it using your solution. Many Thanks

View solution in original post

4 REPLIES 4
v-xiaotang
Community Support
Community Support

Hi @RoyB1973 

I create a sample, the sample not having your data, but the logic is relatively simple, 

In this sample, create a measure to calculate the sum, then judge whether it is greater than 0.

sum =
MIN ( 'Table'[Aantal1] ) + MIN ( 'Table'[Aantal2] )
Points =
VAR _a =
    IF ( [sum] < 0, 0, [sum] )
VAR _b =
    SUMX ( ALL ( 'Table' ), ABS ( [sum] ) )
RETURN
    IF ( ISINSCOPE ( 'Table'[Aantal1] ), _a, _b )

 

 

Then sum its absolute values.

The principe of the dax code is:

   for the 1st row: -2-1= -3 <0, then Points = 0, abs value = abs(-3) = 3,

   for the 2nd row:-1+2= 1 >0, then Points = 1, abs value = abs(1) = 1,

......

So the Total row = 3+1+2+1+1=8

vxiaotang_0-1640332117296.png

So you can try to put the part bellow into a measure, then judge the measure whether it is greater than 0.

vxiaotang_1-1639467323934.png

If you need more help, please let me know. And please provide the sample file or some sample data, so that I can recreate the same pbix file.

 

Best Regards,

Community Support Team _Tang

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

Thanks, I managed it using your solution. Many Thanks

amitchandak
Super User
Super User

@RoyB1973 , If you need negative in total you need to use isinscope  on one or more column 

 

points measure  =

var _1 = Sumx(Table, [Qty]*10)

var _2 = Sumx(Table, if([Qty]<0, 0, [Qty]*10) 

return

if(isinscope(Table[Customer]) , _2, _1)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandakthnx for the quick reply. 

The total of the negative = - 1030. But I don't need that one.
I only want the total in de Points Column to be 5350 and not 5350 - 1030 = 4320.
In the points column you see that when the growth < 0 there are no points. But in the total count these negative numbers are counted.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors