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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
BudMan512
Helper V
Helper V

Two inactive relationships between Customer table and Date table not working

Hey,

I have both Customer and Sales tables that I need to have relationships with the Date table.

The Customer table needs two relationships with the Date table for Gain Date and Loss date.  The Sales table needs a relation with the date table as well.

So far this is the closest model I have.  But it isn't working correctly yet.

 

BudMan512_0-1695918244401.png

Here is my report containing a sales table as well as information about the Gains and Losses of Customers.

Strangely enough the total Losses is correct but the Total Gains are way off.  It should be 29.  I have tried all the different combinaions of active and inactive relationships as well as DAX but can not get the final piece.

Here is a link to the report.  I would appreciate some help with this.

Thanks

https://ruralcomputers-my.sharepoint.com/:u:/g/personal/bingraham_rccbi_com/EScqOFoa5uxNsgH68oSEiNIB...

 

BudMan512_1-1695918478225.png

 

 

 

 

1 ACCEPTED SOLUTION

I found the answer which uses the function TREATAS.  First I removed the inactive relationships.  I then used the following DAX, which worked.

 

Gains = CALCULATE([Count of Customers],

TREATAS(VALUES('Date'[Date]),Customer[Gain Date]))

 

Loss = CALCULATE([Count of Customers],

TREATAS(VALUES('Date'[Date]),Customer[Loss Date])) *-1

 

 

Net Gain/Loss = [Gains]+[Loss]

View solution in original post

3 REPLIES 3
ChiragGarg2512
Solution Sage
Solution Sage

@BudMan512 , Explain the relationships between tables and how those relationships are working.

I found the answer which uses the function TREATAS.  First I removed the inactive relationships.  I then used the following DAX, which worked.

 

Gains = CALCULATE([Count of Customers],

TREATAS(VALUES('Date'[Date]),Customer[Gain Date]))

 

Loss = CALCULATE([Count of Customers],

TREATAS(VALUES('Date'[Date]),Customer[Loss Date])) *-1

 

 

Net Gain/Loss = [Gains]+[Loss]

I am attempting to use one Date table  for connecting to the Sales table and Customer table.  The Date table has an active relationship with Sales.  The Customer table is connected with two inactive relationships so I can count the Gain Dates and Loss Dates.  This arrangement is not working so I am looking for a way to make it work.  I am open to suggestions.

Here is the DAX for the two inactive relationships that I am having a problem with.

 
Total Gains = COUNTA(Customer[Gain Date])  (I don't know how to make this relationship Active)
Total Losses = CALCULATE([Total Gains], USERELATIONSHIP(Customer[Loss Date],'Date'[Date])) * -1
Thanks for taking the time to reply.
 
 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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