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
lefinalzugzwang
Frequent Visitor

Implementing a date table without interfering with existing relationships

Hi all, 

I am trying to compare data from my Sales table, to data in my Forecasts table. I have two different date fields involved here. Forecast.Date which is the date that a particular sale from Forecasts is predicted to take place, and Sales.Date which is the actual date when a particular sale took place. Below is a screengrab of my schema.

 

Model.png

 

As you would expect, everything revolves around products! So here's the question... Obviously there are many tables here which have a date field. As of yet I haven't been able to properly analyse disparate tables by date in a single visual. I know that I probably need a date table. But I don't fully understand how to create relationships between these dates/date table without disrupting the schema and hence other relationships.

For example, if I wanted to create a matrix with Product.Name as the rows, and then Months as columns, and as values have Forecast.Value and Sale.Value as my values. At the moment the date filtering only works for one set of these values. But when I try to implement the Date Table between forecast.date and sale.date I lose one of the relationships between these and the product table. 

I've tried to be as clear as possible, apologies if this doesn't come through!

L

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @lefinalzugzwang,

 

>>But I don't fully understand how to create relationships between these dates/date table without disrupting the schema and hence other relationships.

 

For the date table, I'd like to suggest you create with all tables date fields, for example:

 

Date Table = 
var temp=DISTINCT(UNION(VALUES(Table1[Date]),VALUES(Table2[Date]),VALUES(Table3[Date]),...))
Return
CALENDAR(MINX(temp,[Date]),MAXX(temp,[Date]))

 

 

Then you can create one to many relationship from calendar table to each other table which contains the date field, use calendar table as source of the filter.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3

Turn off the bidirectional filtering in your current relationships. Then you can add your date table without any problems. Send me a pm with your email address and I will send you a pre release of my blog article on this topic (not due for release until 14 Feb



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Thanks a lot for this, it does sort of make sense that the relationships should be set up like this, and it's what I did. I am going to pm you once I figure out how to do so!

v-shex-msft
Community Support
Community Support

Hi @lefinalzugzwang,

 

>>But I don't fully understand how to create relationships between these dates/date table without disrupting the schema and hence other relationships.

 

For the date table, I'd like to suggest you create with all tables date fields, for example:

 

Date Table = 
var temp=DISTINCT(UNION(VALUES(Table1[Date]),VALUES(Table2[Date]),VALUES(Table3[Date]),...))
Return
CALENDAR(MINX(temp,[Date]),MAXX(temp,[Date]))

 

 

Then you can create one to many relationship from calendar table to each other table which contains the date field, use calendar table as source of the filter.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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.