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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ChrisBroome
Frequent Visitor

Custom Column error with Missing Data

Hi,

 

I currently have a column 'Done' where Rows contain either a date, or are blank. I'm creating a new custom column that turns these dates into 'week commencing' dates. my query so far is;

 

#"Inserted Start of Week" = Table.AddColumn(#"Filtered Rows", "Start of Week", each Date.StartOfWeek(DateTime.From([Done])), type datetime)
in
#"Inserted Start of Week"

 

This works for those rows with dates, but throws errors where the row is blank. My thought was to include an 'otherwise null' expression, but whatever I try results in either a 'token literal expected' or 'token comma expected' syntax error.

 

Can anyone help?

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @ChrisBroome 

Try this

 

= Table.AddColumn(#"Filtered Rows", "Start of Week",  each try Date.StartOfWeek(DateTime.From([Done])) otherwise null)

 

Phil


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

2 REPLIES 2
PhilipTreacy
Super User
Super User

Hi @ChrisBroome 

Try this

 

= Table.AddColumn(#"Filtered Rows", "Start of Week",  each try Date.StartOfWeek(DateTime.From([Done])) otherwise null)

 

Phil


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


@PhilipTreacy 

Doh, obvious now! 

 

thanks!

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

Top Solution Authors
Top Kudoed Authors