cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
ConorHG Regular Visitor
Regular Visitor

Date Relationship

Hi, 

 

I am struggling with doing a date relationship. 

I have created a calendar table and added several columns. 

 

In both data view and query editor, I have put the dates I am doing the relationship on in date datatype and I can do the relationship.

But I then receive the below error after the relationship. It seems that after doing the join the date field in the facts column is no longer read as a date? 

 

BedDaysCal.PNG

 

This calc works perfectly before I do the relationship.

 

DateColumn.PNG

 

Any help is appreciated. 


Thanks, 
Conor.

1 ACCEPTED SOLUTION

Accepted Solutions
FarhanAhmed1984 Regular Visitor
Regular Visitor

Re: Date Relationship

I think since you are creating relationship of disdate and date table using date column that's why you are limiting the capabilities of date data. Therefore if you need to have all the capabilities for date values (hierarchy) then you should create a DateKey (Integer Value) on both tables and then join it on that. After that you will see all the hierarchy for your date values.

View solution in original post

8 REPLIES 8
FarhanAhmed1984 Regular Visitor
Regular Visitor

Re: Date Relationship

Looks like disdate is not a Date Column.

 

- Click on field.

- Click on Modelling tab

- See if data type is Date , change it to date if it is not.

.DataType.jpg

 


Thanks

 

ConorHG Regular Visitor
Regular Visitor

Re: Date Relationship

Hi @FarhanAhmed1984

 

All my date columns are in the correct format. 

 

DisDate.png


Thanks, 
Conor.

FarhanAhmed1984 Regular Visitor
Regular Visitor

Re: Date Relationship

Try this.

 

No Bed Days = DateDiff(FIRSTDATE('Hipe Data'[AdmDate]),FIRSTDATE('Hipe Data'[DisDate]),DAY)

 

DateDiff takes Scalar as Input, so you need to have 1 value return for each input.


You may use MAX() or MIN() as well instead of FIRSTDATE

ConorHG Regular Visitor
Regular Visitor

Re: Date Relationship

Thanks @FarhanAhmed1984, that does work for the calc but it also works if I just remove the '.[date]' from 'disdate'. 

 

The problem I'm having seems to be more with the disdate column, without a relationship it works as a date column including date hierarchy.

 

But when I use it in a relationship with a calendar table I have created I can no longer use it as a date hierarchy and it no longer works in the calc it previously worked in. 

 

Relationship.png

 

Thanks,

Conor.

FarhanAhmed1984 Regular Visitor
Regular Visitor

Re: Date Relationship

If your calculation uses Date from Date table then it wont work because it is many to one relationship between these two fields. there can be multiple discharge dates for same dates.

 

Otherwise relationship created from YourTable to DateTable won't have any affect on calcualtion.

 

What exactly you are getting when you are creating relationship from Date table ?

 

 

 

 

ConorHG Regular Visitor
Regular Visitor

Re: Date Relationship

When I create the relationship I get the error in my initial post but if I delete the relationship, the calc works perfectly as it is in the initial post. 

The calc isn't using any of the fields from the DateTable just columns from the FactsTable. 

 

So I don't understand what the relationship is doing to stop "'Hipe Data'[DisDate].[Date]" from working when it worked before the relationship? 

 

Appreciate your patience!
Conor.

FarhanAhmed1984 Regular Visitor
Regular Visitor

Re: Date Relationship

I think since you are creating relationship of disdate and date table using date column that's why you are limiting the capabilities of date data. Therefore if you need to have all the capabilities for date values (hierarchy) then you should create a DateKey (Integer Value) on both tables and then join it on that. After that you will see all the hierarchy for your date values.

View solution in original post

ConorHG Regular Visitor
Regular Visitor

Re: Date Relationship

Thanks @FarhanAhmed1984 think I kind of understand it now. 

Helpful resources

Announcements
Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors