Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
dolevh
Helper II
Helper II

DAX Column - use another value if field is blank

Hi all, 

I have a 'Customer' Table: 

 

ID   Date1   Date2
1   1/1/2021 
2   1/2/2021 
3    1/3/2021
4    1/4/2021 
5   1/5/2021   1/5/2021

 

I need a dax that unit the column Date 1 with Date 2 just if Date2 is empty. 

For example: 

 

ID   Date1   Date2   NewColumn
1   1/1/2021    1/1/2021
2   1/2/2021    1/2/2021
3    1/3/2021   1/3/2021
4    1/4/2021    1/4/2021 
5    1/5/2021    1/5/2021   1/5/2021

 

Thanks All.

1 ACCEPTED SOLUTION

If they're both from the same table, then there shouldn't be any problem writing a calculated column on that same table as I suggested and I don't know why you say you can't find them.

 

Of course, if you're defining a measure, then you need to use an aggregation function since there isn't any row context like there is in a calculated column. For example,

Measure1 = COALESCE ( MAX ( Customer[Date1] ), MAX ( Customer[Date2] ) )

View solution in original post

7 REPLIES 7
AlexisOlson
Super User
Super User

This seems like a good situation for COALESCE:

COALESCE ( Customer[Date1], Customer[Date2] )

 

With COALESCE function I can't find the columns 'Date1' and 'Date2' in my table. 
Do you know why? @AlexisOlson  
Thank you!

I was assuming that those were your columns on your table and suggesting how to define a new calculated column. If they aren't in your table, then you'll need to explain where they are since you haven't shared your file.

I took the columns from two different tables but I created one table with all these columns in power query (after merging between tables).

I don't follow.

 

Replace the column references I gave with whatever column or value they should be. If they're measures, then remove both 'Customer' table references from what I gave and it should work as a measure. If they aren't columns from the same table or measures, then you need to provide more information.

This is two columns from the same table, tell me which information do you need please.

Thank you!

If they're both from the same table, then there shouldn't be any problem writing a calculated column on that same table as I suggested and I don't know why you say you can't find them.

 

Of course, if you're defining a measure, then you need to use an aggregation function since there isn't any row context like there is in a calculated column. For example,

Measure1 = COALESCE ( MAX ( Customer[Date1] ), MAX ( Customer[Date2] ) )

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.