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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
bdd9
Frequent Visitor

DAX calculate formula with filters...I'm Confused

I have successfully written a formula that returns sales quantity from my fact table. the filters in the formula work even though my fact table (NS_Transactions) DOES NOT have a relationship with my dimension item table (NS_Items). However, when I create the relationship between the 2 tables, the formula breaks and returns nothing.  

 

Why would the filters and the formula work BEFORE there is even a relationship but not AFTER?

 

Here is the formula:

 

SalesQty_m = CALCULATE(

-sum(NS_Transactions[Qty]),

filter(NS_ITEMS,NS_ITEMS[TYPE_NAME]="Inventory Item"),

FILTER(NS_Accounts,NS_Accounts[TYPE_NAME]="Income")

)

 

Here is the accurate results BEFORE I create the relationship:

before.JPG

HEre is blank result I get after:

after.JPG

Here is a screenshot of the the relationship

relationship.JPG

1 ACCEPTED SOLUTION
bdd9
Frequent Visitor

Mystery solved...

The formula works perfectly...

The problem was I passed incorrect Type_Name in the filter for the item. Hence, the reason I was getting correct results without the item relationship was because that filter was not working anyway. In essence I didn;t need that filter to get the correct result AND I was using an incorrect parameter in the filter

 

Once I corrected that issue, I get the desired result

 

Thanks for your help and patience

View solution in original post

3 REPLIES 3
prateekraina
Memorable Member
Memorable Member

Hi @bdd9,

 

Check relationship with NS_Accounts table. 

 

 

Prateek Raina

Thank you for replying and offering help 🙂

A relationship does exist. 

I double checked the relationship between ns_transactions and ns_accounts. Here is a screenshot of it:

relationshipaccts.JPG

bdd9
Frequent Visitor

Mystery solved...

The formula works perfectly...

The problem was I passed incorrect Type_Name in the filter for the item. Hence, the reason I was getting correct results without the item relationship was because that filter was not working anyway. In essence I didn;t need that filter to get the correct result AND I was using an incorrect parameter in the filter

 

Once I corrected that issue, I get the desired result

 

Thanks for your help and patience

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.