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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
pawelj795
Post Prodigy
Post Prodigy

Sum rows only with specific values in other column

Hi,
I have database with inventory values like below. (sample data)
image.png

Now, I want to create measure, which gonna calculate YTD value, but only for Items, which never had Transtype 0 or 9.

12 REPLIES 12
Anonymous
Not applicable

Hi @pawelj795 . May be like this? SUM = CALCULATE(SUM(Value),Transtype <> 0,Transtype<>9)

@Anonymous 
That would be too easy 😉

I want to calculate YTD Value for items, which NEVER had TransType 0 or 9.
I mean by this, that some items could have all type of transactions (TransType) within a year.

Hi @pawelj795 ,

 

First you need to create a calculated column as below:

 

year = YEAR('Table'[Date])

 

It is to get the year of your date,then,you need a measure as below:

 

Measure = 
CALCULATE(SUM('Table'[Visitors]),FILTER('Table','Table'[Trans_ type]<>0&&'Table'[Trans_ type]<>9))

 

Finally put your year column in the slicer, and measure in a card,and you will see :

Annotation 2020-02-11 161609.png

You can choose any year you like to calculate the totalYtd value.

 

Here is my .pbix file,pls click here.

 

Best Regards,
Kelly

 

@v-kelly-msft 

Nope, it's not what I'm looking for.

 

Look on screenshot with my real data.
image.png


In my report, I need to exclude Items with no TransType 0 or 9.
I don't want to only exlude transactions, but whole Item.

 

In above example, Item with number 1-2-0105-0052 should be exclude entirely from my matrix.

Hi @pawelj795

 

First add a calculated column :

 

Column = 
var a=SEARCH(0,'Table'[ItemID],1,0)
var b=SEARCH(9,'Table'[ItemID],1,0)
Return
IF(a=0&&b=0,1,0)

 

Then correct measure as below:

 

 

Measure = 
CALCULATE(SUM('Table'[Visitors]),FILTER('Table','Table'[Trans_ type]<>0&&'Table'[Trans_ type]<>9&&'Table'[Column]=1))

 

For the related .pbix file,pls click here.

 

 
Best Regards,
Kelly

Hi @v-kelly-msft 

Shouldn't be TransType instead of ItemID in below measure and also OR instead of AND?

Column = 
var a=SEARCH(0,'Table'[ItemID],1,0)
var b=SEARCH(9,'Table'[ItemID],1,0)
Return
IF(a=0&&b=0,1,0)

 

Column =
VAR A = SEARCH(0;WH_Invent_Trans[TransType];1;0)
VAR B = SEARCH(9;WH_Invent_Trans[TransType];1;0)

RETURN
IF (A=0 || B=0;1;0)

Hi @pawelj795 ,

 

a=0 means there's no 0 in the column, so is b ,so a=0&&b=0 means there's no 0 or 9 in column ID, you said all the rows which contains 0 or 9 in column ID and TransType should all be excluded...so in my measure I have excluded all the posibilities.I have checked my result,it satisfies your need,where do you find not work?

 

Best Regards,
Kelly
 
Did I answer your question? Mark my post as a solution!

Hi @v-kelly-msft,
I tried to do what I want in your file and it still doesn't work.
Look on shared pbix.


https://drive.google.com/open?id=1DpCDU2v4xJwMyeXjbFMCJX5RAFQEZg6N

image.png

ItemID's which I marked should be also on the table rightward.
Why they aren't?

@v-kelly-msft 

Even with my above adjustments or with precisely your measure, it still only exlude transactions with trans type 0 or 9, not whole Index (ItemID)

@v-kelly-msft 
It's possible to do what I want?

up

pawelj795
Post Prodigy
Post Prodigy

up

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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