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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
dw700d
Post Patron
Post Patron

Calculate Sum FILTER

I am trying to create a measure that gives me the total sum  when the Tract column is blank, the Loc Cd begins with Z and the AMT column is greater than 0.

 

In the sample below, the total sum should be 120 based on my criteria

 

IndexLoc CDAmtTract
1Z1234100 
2Z1234-70 
3Z1234-100 
4Z123420 
5Z123410123
          6Q3344        20 

 

 

I tried using the formula below but  something isn’t working correctly. Any suggestions would be greatly appreciated

 

 

Wireless Outside QOZ = CALCULATE(SUM('BIP+ In service'[Amt]),

FILTER(' BIP+ In service',' BIP+ In service'[Tract] = BLANK()

),

FILTER(' BIP+ In service',LEFT(' BIP+ In service'[Loc Cd],1)="Z"),

FILTER(' BIP+ In service',' BIP+ In service'[Amt]>0))

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @dw700d ,

 

Check the measures.

Include<0:

Measure = CALCULATE(SUM('Table'[AMT]),FILTER(ALLSELECTED('Table'),'Table'[Tract]=BLANK()&&'Table'[loc Cd]=SELECTEDVALUE('Table'[loc Cd])&&LEFT(SELECTEDVALUE('Table'[loc Cd]),1)="Z"))

Aggregate value>0:

Measure 2 = 
var flag = CALCULATE(SUM('Table'[AMT]),FILTER(ALLSELECTED('Table'),'Table'[Tract]=BLANK()&&'Table'[loc Cd]=SELECTEDVALUE('Table'[loc Cd])&&LEFT(SELECTEDVALUE('Table'[loc Cd]),1)="Z"))
return
IF(flag>0,flag,BLANK())

1.PNG

 

Best Regards,

Jay

View solution in original post

10 REPLIES 10
Anonymous
Not applicable

Hi @dw700d ,

 

Check the measures.

Include<0:

Measure = CALCULATE(SUM('Table'[AMT]),FILTER(ALLSELECTED('Table'),'Table'[Tract]=BLANK()&&'Table'[loc Cd]=SELECTEDVALUE('Table'[loc Cd])&&LEFT(SELECTEDVALUE('Table'[loc Cd]),1)="Z"))

Aggregate value>0:

Measure 2 = 
var flag = CALCULATE(SUM('Table'[AMT]),FILTER(ALLSELECTED('Table'),'Table'[Tract]=BLANK()&&'Table'[loc Cd]=SELECTEDVALUE('Table'[loc Cd])&&LEFT(SELECTEDVALUE('Table'[loc Cd]),1)="Z"))
return
IF(flag>0,flag,BLANK())

1.PNG

 

Best Regards,

Jay

dw700d
Post Patron
Post Patron

@VahidDMThanks for the response. I would like a measure that identifies any Loc CD with A first letter that begins with Z, where the Tract column = blank and any Loc CD where the aggreagte value is greater than 0. In the example below I have two "Loc CD's" Z1234 & Z5678 the measure would only return  an amount for "Loc CD" Z5678  because the aggregate value of all its transacations is greater than 0 (-50,-10,20,80). The amount would be 40.

 

The measure would not return an amount for Z1234 because the aggregate value of all Z1234 transactions is negative (100,-70,-100,20)

 

 

Index    LocCD                  AmtTract   
1Z1234100 
2Z1234-70 
3Z1234-100 
4Z123420 
6Z5678-50 
7Z5678-10 
8Z567820 
9Z567880 

 

Does this help?

@dw700d 

 

Try this measue:

Measure = 
VAR _A =
    FILTER (
        SUMMARIZE (
            'Table',
            'Table'[LocCD],
            "S",
                CALCULATE (
                    SUM ( 'Table'[Amt] ),
                    FILTER ( 'Table', NOT ( ISBLANK ( 'Table'[Trac] ) ) )
                )
        ),
        [S] > 0
    )
RETURN
    SUMX ( _A, [S] )

 

 

output:

VahidDM_0-1642485996963.png

 

 

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

@VahidDM  thank you for working with me. Something is a bit off, this measure is only giving me data where the "Tract" column contains information. I need the "Tract" column to be blank. How would I tweak this measure to accomplish that? In the example below "Loc Cd" Z0000 would not return a value because the "Tract" column is not blank

 

 

Index    LocCD                  Amt       Tract              
1Z000020       ABC
2Z1234100 
3Z1234-70 
4Z1234-100 
5Z123420 
6Z5678-50 
7Z5678-10 
8Z567820 
9Z567880 

 

Ashish_Mathur
Super User
Super User

Hi,

Try these measures:

Amount = SUM(Data[Amt])
Measure1 = CALCULATE([Amount],FILTER(Data,Data[Amount]>0&&Data[Tract]=BLANK()&&LEFT(Data[Loc CD],1)="Z"))

Drag Measure1 to your visual.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur  I think I realize my issue, I am looking to identify when amt is greater than 0 at the Loc Code level. 

So what I am really trying to do is  create a measure that gives me the total sum  when the Tract column is blank, the Loc Cd begins with Z and the loc Cd is greater than 0 based on the AMT column. Thanks for your help

Hi,

Please take a comprehensive example to pressent your case.  Take multiple LocCD's and for those show entries in the Tract numbers as well.  On that comprehensive example, show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Good day @Ashish_Mathur see below

 

Transactionloc CdAMT       Tract              
1Z000020       ABC       
2Z1234100 
3Z1234-70 
4Z1234-100 
5Z123420 
6Z5678-50 
7Z5678-10 
8Z567820 
9Z567880 
10Z9999-10ABC
11Z999930ABC
12A123420 
13A123430 
14Z111140 
15Z111170 
16Z3333100ABC
17Z333320ABC
18V1111-20 
19V1111-25 
20V111150 
21Z888850ABC
22Z8888-10ABC

 

 

 

The end result is in the pivot table visual below. It shows  Loc Cd's that begin with Z, have a blank in the tract column and the sum of all the individual transactions affilliated with that loc cd is greater than 0

 

 

dw700d_1-1642552586548.png

 

 

Hi,

Here's a simple solution

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@dw700d 

 

What does this mean:  loc Cdis greater than 0

can you can add a expected output as well?

 


Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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