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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Kalai20078
New Member

Sum of Negative and positive values seperately in a Measure

Hi,

 

I need some help on sum the Negative and Positive values within a measure seperately.

 

Eg. I have the following measure 

 

Difference
-0.4375
0
0
0
-0.2
0
0.7875
0.055
-0.77875
0.5
0.3
0
0
-0.8
-0.125
0.1125
-0.2

 

Since it a measure I have problems in using the CALCULATE or SUM or any other ways to calculate the sum, I nee to calculate only the negative values and have it in a measure then sum the psoitive values and have it in a different measure. 

 

Result should be  -254 for negative sum and 1.7 for the positive.

 

Please it would be great if some one could help me.

 

 

 

1 ACCEPTED SOLUTION

@Kalai20078

 

Sorry I overlooked that it is a MEASURE

 

Which column do you use as row field

Try this. Replace the Column with RowField

PositiveCount =
SUMX (
    FILTER ( ALLSELECTED ( TableName[COLUMN] ), [Difference] > 0 ),
    [Difference]
)

Regards
Zubair

Please try my custom visuals

View solution in original post

6 REPLIES 6
crnswengineer
Frequent Visitor

i have a same problem but i dont understand what do you mean "Replace the Column with RowField"?@Zubair_Muhammad

SivaMani
Resident Rockstar
Resident Rockstar

@Kalai20078,

 

Hope! this is what you're looking for,

 

Posstive = CALCULATE(SUM(Table1[Difference]),Table1[Difference] > 0)

Negative = CALCULATE(SUM(Table1[Difference]),Table1[Difference] < 0)

@SivaMani thaks for the reply

 

I have tried this earlier with lot other however the problem was that the difference column shown itself is a measure not the column and so it is not possible to use the measure in place of column, any other thoughts?, 

 

I brought the negative and positive values in a speperate measures respectively but you know the total will not be the one as expecteed in a measure put up like this,, so stuck here....

Zubair_Muhammad
Community Champion
Community Champion

@Kalai20078

 

Try this

 

PositiveCount =
CALCULATE ( SUM ( TableName[Difference] ), TableName[Difference] > 0 )

Regards
Zubair

Please try my custom visuals

@Zubair_Muhammad Thanks for your reply,

 

Here you mean the column 

SUM ( TableName[Difference]

However mine was a measure (The difference Iam calculating is already withing a measure), I not able to use a measure here.

 

@Kalai20078

 

Sorry I overlooked that it is a MEASURE

 

Which column do you use as row field

Try this. Replace the Column with RowField

PositiveCount =
SUMX (
    FILTER ( ALLSELECTED ( TableName[COLUMN] ), [Difference] > 0 ),
    [Difference]
)

Regards
Zubair

Please try my custom visuals

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors