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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

iF ELSE statment with a calculation for a custom colum

Hello

 

Im trying to figure out how to get a colum to if else. 

 

I have a colum for completetion date of course and one with the number of years until retraining and I am trying to calculate the expiry date based on 

If completion date = null then "course has not started" else Date.AddYears([Completion Date],[Sheet1.Retraining])

 

I can currently just add the retraining colum to the completetion date and this gives me a result of the rows that have a completion date. But then I have error for all the ones that have Null instead. 

 

Anyone have any suggestions to achieve this. 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Please check the error message. I reckon it is because of the Data type mismatch between the 2 results.

1. "course has not started" is text data type

2. Date.AddYears([Completion Date],[Sheet1.Retraining]) will have date datatype.

 

My suggestion is:

1. Create a new column "Actual Completion Date Text" with expression: Date.AddYears([Completion Date],[Sheet1.Retraining]). 

2. Convert this to Text data type.

3. Add conditional column "Completion Date"

If If completion date = null then (text value) "course has not started" else (column) "Actual Completion Date Text".

 

This will ensure you have same data type for both if else ouptut.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Worked perfectly, Thank you 🙂 

Anonymous
Not applicable

Please check the error message. I reckon it is because of the Data type mismatch between the 2 results.

1. "course has not started" is text data type

2. Date.AddYears([Completion Date],[Sheet1.Retraining]) will have date datatype.

 

My suggestion is:

1. Create a new column "Actual Completion Date Text" with expression: Date.AddYears([Completion Date],[Sheet1.Retraining]). 

2. Convert this to Text data type.

3. Add conditional column "Completion Date"

If If completion date = null then (text value) "course has not started" else (column) "Actual Completion Date Text".

 

This will ensure you have same data type for both if else ouptut.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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.