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
jmetf150
Helper I
Helper I

DAX - If "Date1" is blank, then "Date2", if both are blank, "Date 3"

Hello - I am looking for assistance to help me learn writing DAX formulas concerning dates and blanks.  This would be very similar to an "IF" statement but trying to understand if IF or SWITCH would be better for what I need.

 

Per the below table, I am trying to write a formula that will tell me this:

 

Show me Org date unless there is a Res date, then show me the Res date.  If both are blank, show me the Del date.

 

OrgResDelNew (Outcome)
5/26/906/28/906/15/91      6/28/90
3/5/91 4/25/91      3/5/91
  6/15/91      6/15/91
3 ACCEPTED SOLUTIONS
Dangar332
Super User
Super User

Hi, @jmetf150 


it depend on your conditions 

if you have one or two condition then use IF() function .you can use if  when more then two condition but it little bit hard .

if you have more than two condition then easy to use switch() function. but in switch sequence matter if sequence is not in correct order then it give unexpected result

 

With IF() function

 

column =
  if(
   tablename[res]<>blank(),tablename[res],
    if(
     tablename[org]<>blank(),tablename[res],tablename[del]
    )
   )

 

 

With switch() function

 

column=
switch(
  true(),
  tablename[res]<>blank(),tablename[res],
  tablename[org]<>blank(),tablename[org],
 tablename[del]
)

 

 

Dangar332_0-1703917715973.png

 

View solution in original post

ThxAlot
Super User
Super User

= COALESCE( [Res], [Org], [Del] )



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



View solution in original post

Thanks Alot ThxAlot!  🙂  I tried your proposed solution first because it was very simple to write/understand (at least for a newbie anyway).  I am going to read more about the COALESCE function to better understand its purpose and when to use it.

View solution in original post

8 REPLIES 8
ThxAlot
Super User
Super User

= COALESCE( [Res], [Org], [Del] )



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



Thanks Alot ThxAlot!  🙂  I tried your proposed solution first because it was very simple to write/understand (at least for a newbie anyway).  I am going to read more about the COALESCE function to better understand its purpose and when to use it.

Dangar332
Super User
Super User

Hi, @jmetf150 


it depend on your conditions 

if you have one or two condition then use IF() function .you can use if  when more then two condition but it little bit hard .

if you have more than two condition then easy to use switch() function. but in switch sequence matter if sequence is not in correct order then it give unexpected result

 

With IF() function

 

column =
  if(
   tablename[res]<>blank(),tablename[res],
    if(
     tablename[org]<>blank(),tablename[res],tablename[del]
    )
   )

 

 

With switch() function

 

column=
switch(
  true(),
  tablename[res]<>blank(),tablename[res],
  tablename[org]<>blank(),tablename[org],
 tablename[del]
)

 

 

Dangar332_0-1703917715973.png

 

Thank you for your solution.  Both the IF and SWITCH worked also.

gmsamborn
Super User
Super User

Hi @jmetf150 

 

Would something like this help?

 

NewDate = COALESCE( [Res], COALESCE( [Org], [Del] ) )

 

It should be able to be used as a calculated column or as a measure.



Proud to be a Super User!

daxformatter.com makes life EASIER!

What is the difference between a "Calculated Column" and a "Measure"?  Why would you use one over the other?  What are the benefits of using either?

Hi @jmetf150 

 

After re-reading your question, I realized my answer was specific to this thread.

 

If you need a more general description, this should get you started.

https://dash-intel.com/powerbi/modeling_measure+calculated+columns.php#:~:text=A%20measure%20is%20so....

 



Proud to be a Super User!

daxformatter.com makes life EASIER!

Hi @jmetf150 

 

One example of using a calculated column is if all 3 dates are columns from the same table.  If the result is not meant to be dynamic, a calculated column would work since they are only evaluated once at refresh time.

 

One example of using a measure would be if the 3 dates are measures.  The tables in the underlying measures could be different tables.  By building the logic into the new measure, you could handle a dynamic scenario in which the result would be affected by slicers, filters, etc.

 

I hope this makes sense.

 

(Thumbs up to @ThxAlot  because until now I thought COALESCE() only had 2 parameters.)



Proud to be a Super User!

daxformatter.com makes life EASIER!

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.