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
Tevon713
Helper IV
Helper IV

sum value if less than 0

Hi.

 

Trying to sum a data field only if the sum of it is < 0 else do not sum it or return 0. IF statement or filter be best. I have over 3M records.

 

For example.

Acct # Count
999727 1
999727 -2
992592 0
992035 1
992035 -2
986977 -2
986977 2
936300 -1
1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

 

 

Sum count 1 =
 VAR _tbl = ADDCOLUMNS(VALUES(Data[Acct #]),"SUM", [Sum Count])
RETURN
CALCULATE([Sum Count],_tbl)
or
Sum count 1 =
 VAR _tbl = ADDCOLUMNS(VALUES(Data[Acct #]),"SUM", [Sum Count])
RETURN
sumx(_tbl,[SUM])

 

 

View solution in original post

3 REPLIES 3
Ahmedx
Super User
Super User

 

 

Sum count 1 =
 VAR _tbl = ADDCOLUMNS(VALUES(Data[Acct #]),"SUM", [Sum Count])
RETURN
CALCULATE([Sum Count],_tbl)
or
Sum count 1 =
 VAR _tbl = ADDCOLUMNS(VALUES(Data[Acct #]),"SUM", [Sum Count])
RETURN
sumx(_tbl,[SUM])

 

 

Ahmedx
Super User
Super User

CALCULATE(SUM('tabl'[Count]),'tabl'[Count]<0)

Thanks but didn't yield the answer I'm wanting. Sum only if the sum of the count is <0.

 

 

Sum Count = SUM(Data[Count])
Sum count 1 = CALCULATE(SUM(Data[Count]), Data[Count]<0)

 

Tevon713_0-1679494604619.png

 

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.