Forum Discussion
Relationship problem between date columns from 2 tables
- 7 years ago
And furthermore, it has to be done in the query editor. Does not work if you attempt to do it from the normal modelling pane!
I'm pretty terrible when it comes to SQL :-) But if you can upload a version with with import connectivity, i can take a look at that one instead.
I made a csv from the sql data.
Then imported in power bi.
When I try to change the type of the date column to "Date" I get following error:
- WimVan7 years agoHelper I
Problem solved! Also with direct query.
The problem indeed was that I didn't to the conversion to date type with the query editor.
So even if in the model it "showed" like Date, actually the dates itself were still date/time.
As a result it couldnt match the date/times of my sql table with the dates of the calendarauto because the date/times in sql contain hours and seconds (like 23:04:05) while the calendar dates have all of them 00:00:00.
Below proof of success:
I do think it is confusing that you can change type in the model while it's actually having only superficial effect.
Thanks a lot guys for helping me out on this, especially tex628 for your patience!
- WimVan7 years agoHelper I
Here is a link to the csv:
https://drive.google.com/open?id=13xtd9hGe46ijpXKltOz12SnrurLx5YdH
- tex6287 years agoCommunity Champion
I got it to work with the csv without any problems..
Both the date columns had to be converted to date format but otherwise i did nothing but import it and create the relationship, very strange indeed.
- WimVan7 years agoHelper I
How did you manage to set the "proposal date" column to type "date"?
As I said I get an error and was not able to continue.
What I do is clicking the proposal date in the right side pane, then in the top menu change to "Date" in the data type dropdown. However then i got that error (see screenshot in previous post)
- tex6287 years agoCommunity Champion
When proposal date is imported as CSV, the dataformat is automatically set to text/string. As the string contains timestamps aswell it can only be converted to datetime, and not to date directly. Therefore you need to first convert it to datetime and then convert it from datetime to date in a new step!
- tex6287 years agoCommunity Champion
And furthermore, it has to be done in the query editor. Does not work if you attempt to do it from the normal modelling pane!