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
Canknucklehead
Helper II
Helper II

Calculated Date Column Showing Underlying Date

This is a strange issue.

 

In a Table, I have a Last Received date column. Due to a quirk in the database, this column may contain invalid dates - 0001-01-01 or 9999-12-31. These dates, of course, cause problems with visuals and date calculations. So I created a new column using this code:

Received to Stock = if([Last Received to Stock] = date(0001,01,01) || [Last Received to Stock]=date(9999,12,31),blank(), [Last Received to Stock])  In the Received to Stock column, invalid dates now simply show as blank. This is done at the Dataset level.
 
When I create a report using this dataset, something is causing this Received to Stock column to sometimes display a blank and other times to show the invalid date from the parent column and I can't understand why.
 
In Power Query in the dataset, the raw data shows here:
Canknucklehead_1-1626718254123.png
 
In the table view, the last three columns are all calculated and show correct information. Power BI doesn't display the invalid date in the Last Received to Stock column in this view - it simply shows as blank. This dashboard is to be utilized by Purchasing to allow them to track vendor performance. Being able to filter just the Open Orders is a must. Sorting On Time vs Late or Early is useful as well.
Canknucklehead_2-1626718287098.png

 

If I try and create a visual in the report using the Received to Stock column, I have three problems. 

Problem 1 - by default, it displays as Date Hierarchy. This will show a date of December 30, 1899. Changing the display to just be Recieved to Stock changes the output to a Blank. I do not understand why this column still sees the underlying invalid date information if I have set it specifically to be blank.

Problem 2 - the Blank output only displays if the PO Number column is included in the visual, and only the PO Number column. If I add in any other columns, it reverts to the December 30, 1899 display.

Problem 3 - the Later or Early and the Days Early or Late columns both change their values based on in a visual to dispaly the information as calculated based on the Dec. 30, 1899 entry. 

Canknucklehead_3-1626718829965.png

 

 Any idea what I'm doing wrong?
 
 
1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@Canknucklehead,

 

It's best to do transformations in SQL or Power Query. Do you have the ability to write custom SQL? If not, you could create a custom column in Power Query:

 

if List.Contains({#date(1,1,1), #date(9999,12,31)}, [Last Received to Stock]) then
  null
else
  [Last Received to Stock]

 

DataInsights_3-1626791702076.png

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
Canknucklehead
Helper II
Helper II

Thank you. That appears to have fixed my issue.

DataInsights
Super User
Super User

@Canknucklehead,

 

It's best to do transformations in SQL or Power Query. Do you have the ability to write custom SQL? If not, you could create a custom column in Power Query:

 

if List.Contains({#date(1,1,1), #date(9999,12,31)}, [Last Received to Stock]) then
  null
else
  [Last Received to Stock]

 

DataInsights_3-1626791702076.png

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.