Forum Discussion
DAX for date column
Hi all,
I am stuck with a DAX if someone can help me.
I have a table with 2 date columns, Column A and Column B.
I want a new column (Column C) that will look and see if there is a value in Column A, if it is blank it picks up the value from Column B. If Column A isn't blank then it populates Column C with that value. As per the table below.
TIA, Emily.
| Column A | Column B | Column C |
| 03/02/2020 | 03/02/2020 | |
| 02/01/2020 | 21/01/2020 | 02/01/2020 |
| 13/01/2020 | 01/02/2020 | 13/01/2020 |
| 19/01/2020 | 03/02/2020 | 19/01/2020 |
| 24/12/2019 | 31/12/2019 | 24/12/2019 |
| 15/12/2019 | 15/12/2019 | |
| 30/12/2020 | 30/12/2020 |
I'm sorry I forget to add the null cases too. Try this:
if [ColumnA] = "" or [ColumnA] = null then [ColumnB] else [ColumnA]Regards,
7 Replies
- AnonymousNot applicable
Hi EmilyM2019 ,
Try the following:
Date = if(isblank('Table'[ColumnA]);'Table'[ColumnB];'Table'[ColumnA])
- ibarrauSuper User
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
- EmilyM2019Helper II
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?
- ibarrauSuper User
I'm sorry I forget to add the null cases too. Try this:
if [ColumnA] = "" or [ColumnA] = null then [ColumnB] else [ColumnA]Regards,