Forum Discussion
DAX for date column
- 6 years ago
I'm sorry I forget to add the null cases too. Try this:
if [ColumnA] = "" or [ColumnA] = null then [ColumnB] else [ColumnA]Regards,
Hi there. You should consider do this in Power Query over the query editor. If you want DAX use the first answer, if you want power query try adding a custom column like this:
if [ColumnA] = "" then [ColumnB] else [ColumnA]
Just ask if columnA is blank and you can get the true false with the columns.
Hope this helps,
Regards
Hi,
Thanks for coming back to me. I'm now trying to do this in Power query but it hasn't worked. Using the add custom column option I have done:
= Table.AddColumn(#"Renamed Columns2", "Custom", each if[Column A]=""then[Column B]else[Column A])
and it isn't working. The only value that is returning in the new custom column is the value of column A.
Any ideas?
- ibarrau6 years agoSuper User
I'm sorry I forget to add the null cases too. Try this:
if [ColumnA] = "" or [ColumnA] = null then [ColumnB] else [ColumnA]Regards,
- EmilyM20196 years agoHelper II
Thank you, this has worked, hurrah.
Just to build on this how would I do:
If column A and column B are blank then return todays date?
- ibarrau6 years agoSuper User
Well it should be similar
if [ColumnA] = "" or [ColumnA] = null then if [ColumnB] = "" or [ColumnB] = null then DateTime.LocalNow() else [ColumnB] else [ColumnA]You can continue adding if statements in the "then" or "else" in case you need them.
Regards,