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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
dshandrov
New Member

Sum only positive values from different rows for a period of time

Hi Guys,

 

I need help with the following case:

 

I have a table with fields for date, item, category and value,

There a three types of items a, b and c, and two types of categories x1 and x2 where 1 means that the value in the value field must remain positive and 2 means that the value must be converted to a negative. 

I need to create a matrix whre I have all the items and calculate the sum of all values (positive and negative) for specific period and show values that after the sum are positive.

 

table

DateItemCategoryValueConverted Valuesum
01-01-23

A

A

x2

x1

2

3

-2

3

1

02-01-23Bx1333
03-01-23Ax24-4-4
04-01-23

C

C

x1

x2

3

1

3

-1

2
05-01-23Cx1111
06-01-23

B

B

x2

x1

3

2

-3

2

1
07-01-23Cx1222
08-01-23Cx25-5-5
09-01-23Bx1111
10-01-23Ax1222

 

result table

ItemResultResult to Show
A-1 
B55
C-1 
total35

 

Can you please help me with some directions?

Thanks!

1 ACCEPTED SOLUTION
Dangar332
Super User
Super User

hi, @dshandrov 

create new column for  converted value

 

Column = 
IF(
    'Table'[Category]="x1" || 'Table'[Value]<0, 
    ABS('Table'[Value]),
    IF(
     'Table'[Category]="x2" || 'Table'[Value]>0
     ,'Table'[Value]*-1
    )
)

 

 

look like below

Dangar332_0-1704535623693.png

 

then use below measure for metrix

 

Measure = 
var a = CALCULATE(min('Table'[Item]),FILTER('Table',SUM('Table'[Column])<0))
var b = CALCULATE(SUM('Table'[Column]),'Table'[Item]<>a)
var c = IF(
          ISINSCOPE('Table'[Item]),
          IF(
             SUM('Table'[Column])<0,
             BLANK(),
             SUM('Table'[Column])
            ),
            b
        )
return
c

 

your result look like below

Dangar332_1-1704535742121.png

 

you can download file click HERE 

View solution in original post

1 REPLY 1
Dangar332
Super User
Super User

hi, @dshandrov 

create new column for  converted value

 

Column = 
IF(
    'Table'[Category]="x1" || 'Table'[Value]<0, 
    ABS('Table'[Value]),
    IF(
     'Table'[Category]="x2" || 'Table'[Value]>0
     ,'Table'[Value]*-1
    )
)

 

 

look like below

Dangar332_0-1704535623693.png

 

then use below measure for metrix

 

Measure = 
var a = CALCULATE(min('Table'[Item]),FILTER('Table',SUM('Table'[Column])<0))
var b = CALCULATE(SUM('Table'[Column]),'Table'[Item]<>a)
var c = IF(
          ISINSCOPE('Table'[Item]),
          IF(
             SUM('Table'[Column])<0,
             BLANK(),
             SUM('Table'[Column])
            ),
            b
        )
return
c

 

your result look like below

Dangar332_1-1704535742121.png

 

you can download file click HERE 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors