Forum Discussion
Stuck trying to remove default date
- 10 years ago
What I am trying to say is that I find it strange that khorseman's suggestion isn't working for you, since it does work for me.
Could be your Power BI desktop version, or may be something with the column type.
Here is what I did.
- Create a sample table with two columns. A text and a date column.
- Fill the table witj some dummy data, including one date with 1-1-1900
- Use Khorseman's suggestion of the value replacer, I can insertt null without issue (see screenshot 1)
- Result after the action can be seen in screenshot 2
= Table.ReplaceValue(#"Changed Type",#date(1900, 1, 1),null,Replacer.ReplaceValue,{"Column2"}) - Since that isn't working for you, you might want to try this work around. (step 6 and beyond)
- Replace 1-1-1900 with 1-1-1901
= Table.ReplaceValue(#"Changed Type",#date(1900, 1, 1),#date(1901, 1, 1),Replacer.ReplaceValue,{"Column2"}) - See what code is generated.
- Try to swap that code, with the code that is genarated for a null value
Good luck
p.s. an alternative would be to edit the SQL statement according to your needs with a CASE statement, you could also try something like
CASE date='1-1-1900' THAN null ESLE date END AS date
Could be a little different based on your datasource, but you can google the specifics of a case statement for your database.
Salvolin:
Thanks for the reply. I am not sure exactly what you are suggesting. Is there another way to replace the Date value other than in the Query Editor?
What I am trying to say is that I find it strange that khorseman's suggestion isn't working for you, since it does work for me.
Could be your Power BI desktop version, or may be something with the column type.
Here is what I did.
- Create a sample table with two columns. A text and a date column.
- Fill the table witj some dummy data, including one date with 1-1-1900
- Use Khorseman's suggestion of the value replacer, I can insertt null without issue (see screenshot 1)
- Result after the action can be seen in screenshot 2
= Table.ReplaceValue(#"Changed Type",#date(1900, 1, 1),null,Replacer.ReplaceValue,{"Column2"}) - Since that isn't working for you, you might want to try this work around. (step 6 and beyond)
- Replace 1-1-1900 with 1-1-1901
= Table.ReplaceValue(#"Changed Type",#date(1900, 1, 1),#date(1901, 1, 1),Replacer.ReplaceValue,{"Column2"}) - See what code is generated.
- Try to swap that code, with the code that is genarated for a null value
Good luck
p.s. an alternative would be to edit the SQL statement according to your needs with a CASE statement, you could also try something like
CASE date='1-1-1900' THAN null ESLE date END AS date
Could be a little different based on your datasource, but you can google the specifics of a case statement for your database.
- MojoGene10 years agoPost Patron
Salvolin:
For some reason, replacing the "1/1/1900" value with "1/1/1901" allowed me to thereafter change the "1/1/1901" to NULL. Go figure. In any event, problem solved.
Thanks for all the attention you paid to this. Above and beyond the call of duty.