0

I am using power query in Excel. I have a date column with date starting in 1/31/2015 and ending 1/31/2022. I have the below line of code that works just fine.

...
#"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"Reading", type number}, {"EM_Date", type date}}),    
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each [EM_Date] <= #date(2021, 12, 31)),
...

Now if I change the code just slightly like below It stops working and gives me an error. "Power Query Expression.Error: The Date value must contain the Date component. Details: 43831"

...
#"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"Reading", type number}, {"EM_Date", type date}}),    
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each [EM_Date] >= #date(2021, 1, 31)),
...

How do I fix this error?

3
  • 2
    I created a list of dates only using =DATE(2015,1,SEQUENCE(7*365+3,1,31)) then loaded to PQ. I made the same filters as shown in your post and didn't get an error. Are you sure the error is happening because of that? Can you post the entire query? Commented Feb 7, 2022 at 20:31
  • 1
    something is wrong with your data or the remainder of your code Commented Feb 7, 2022 at 20:34
  • 1
    I found the error in a prior step... The value [EM_Date] is calculated and the source Column were dates but not set as date type. Thank you FlexYourData and horseyride for looking at my question. Commented Feb 7, 2022 at 21:46

1 Answer 1

1

For those that are coming to this post for answers. What I found is that the Column must be set to Dates. In my case I was calculating dates and the source column was not set as dates.

Hope this helps you!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.