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 September 15. Request your voucher.

Reply
Stuznet
Helper V
Helper V

Nested IF with Condition

Hi all,

 

I'm struggling turning this formula in Exel to Power BI

 

=IF(Date2<>"-",YEAR(Date2),IF(Date3<>"-",YEAR(Date3),IF(Date4<>"-",YEAR(Date4),IF(Date1<>"-",YEAR(Date1),2020))))

2018-10-23_16-24-19.jpg

 

The yellow  column is what I want.

Can someone please help? 

 

Thank you

2 ACCEPTED SOLUTIONS
Greg_Deckler
Community Champion
Community Champion

If this is a calculated column, then it should be:

 

=IF([Date2]<>"-",YEAR([Date2]),IF([Date3]<>"-",YEAR([Date3]),IF([Date4]<>"-",YEAR([Date4]),IF([Date1]<>"-",YEAR([Date1]),2020))))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

@Greg_DecklerThank you Greg. The solution you posted it work but I slighly edited the function. Because the column is a date type it cannot be text "-" so I replaced with BLANK(). 

 

 

Column =IF([Date2]<>BLANK(),YEAR([Date2]),
IF([Date3]<>BLANK(),YEAR([Date3]),
IF([Date4]<>BLANK(),YEAR([Date4]),
IF([Date1]<>BLANK(),YEAR([Date1]),2020))))

 

 

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

If this is a calculated column, then it should be:

 

=IF([Date2]<>"-",YEAR([Date2]),IF([Date3]<>"-",YEAR([Date3]),IF([Date4]<>"-",YEAR([Date4]),IF([Date1]<>"-",YEAR([Date1]),2020))))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_DecklerThank you Greg. The solution you posted it work but I slighly edited the function. Because the column is a date type it cannot be text "-" so I replaced with BLANK(). 

 

 

Column =IF([Date2]<>BLANK(),YEAR([Date2]),
IF([Date3]<>BLANK(),YEAR([Date3]),
IF([Date4]<>BLANK(),YEAR([Date4]),
IF([Date1]<>BLANK(),YEAR([Date1]),2020))))

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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