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
Lucian
Responsive Resident
Responsive Resident

Column contains blank values and this is not allowed for columns on the one side of a many-to-one...

Hello,

 

I have a strange problem when I try to get some data from a single table:

 

Failed to save modifications to the server. Error returned: 'Column 'Enddate only' in Table 'PBI_Projects' contains blank values and this is not allowed for columns on the one side of a many-to-one relationship or for columns that are used as the primary key of a table. '.

 

let
    Source = Dynamics365BusinessCentralOnPremises.Contents("server.com:7148/.../ODataV4/", null),
    ConnName= Source{[Name="ConnName"]}[Data],
    PBI_Projects_table = ConnName{[Name="PBI_Projects",Signature="table"]}[Data],
    #"Changed Type" = Table.TransformColumnTypes(PBI_Projects_table,{{"Starting_date", type datetime}, {"Ending_Date", type datetime}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [Starting_date] >= RangeStart and [Starting_date] < RangeEnd),
    #"Inserted Stdate only" = Table.AddColumn(#"Filtered Rows", "Stdate only", each try DateTime.Date([Starting_date]) otherwise #date(1900, 1, 1), type date),
    #"Inserted Enddate only" = Table.AddColumn(#"Inserted Stdate only", "Enddate only", each try DateTime.Date([Ending_Date])  otherwise #date(1900, 1, 1), type date)
in
    #"Inserted Enddate only"

I have disabled the "autodetect relationships" even is the one and only table.

AutoDetectRelationshipDisabled.png

 

The problem it seemd to be created by the last two lines from the query where I need to extract only the date part from the datet/time columns.

Without that two lines works perfectly, but with them, I have that error message. Is not from the "try... otherwise" section because initially were not used and the error is the same.

 

How can I get another date only column based on the date/time column?...

 

Kind Regards,

Lucian

 

 

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Well, if you can do it in DAX, just use something like:

 

New Date Column = DATE(YEAR([Date]),MONTH([Date]),DAY([Date]))

 

Not sure why you are getting that error in your Power Query code. 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Lucian
Responsive Resident
Responsive Resident

Hello,

 

And thank you all for your responses.

 

@V-lianl-msftIndeed is somehow unclear so I try to explain a little bit more.

The table involved is the Navision's Projects table and the columns "Starting_date" and "Ending_Date" are date/time/timezone type.

All the problems started because I wanted to test the "Incremental refresh" in Power BI Pro that require 2 specific date/time parameters RangeStart and RangeEnd, so in the query I have changed type of the original column to date/time. Then I realized that I need just a date only column to relate to a dimDate table to make other calculations work.

 

The error message could arise because I'm trying to convert a date/time column to a date only column... but the error message is not pointing to the right direction. 🤔

 

Until now @Greg_Deckler 's tip was most usefull, so thank you Greg. 👍

Even I would like to do it in the query, using the DAX for the transformation outside the query will also help preserving the "query folding" that is also required for incremental refresh. 😉

 

So the problem it solved, at least for now.

 

Kind Regards,

Lucian

V-lianl-msft
Community Support
Community Support

Hi @Lucian ,

 

It is very difficult to analyze without looking at the data and just by imagining. See if you can share sample data and expected output.

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Lucian ,

 

Not sure I got it completely.

you can try Date.FromText("2010-02-19") // Date, yyyy-MM-dd 

 

refer:https://docs.microsoft.com/en-us/powerquery-m/date-fromtext

Greg_Deckler
Super User
Super User

Well, if you can do it in DAX, just use something like:

 

New Date Column = DATE(YEAR([Date]),MONTH([Date]),DAY([Date]))

 

Not sure why you are getting that error in your Power Query code. 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.