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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Convert an excel-formula to DAX

Hi,
Can someone help me with converting the following Excel-formula to Dax?

=IF(ISBLANK(F2);IF(YEAR(E2)=2021;(-MONTH(E2)+12)/12;1);MONTH(F2)/12)

Any help is greatly appreciated!

Regards,
sondi

2 REPLIES 2
v-chenwuz-msft
Community Support
Community Support

Hi @Anonymous ,

 

@amitchandak  is right if you want to create columns in power bi. I make some additions. If you want create measure, the parameter of ISBLANK() can not be [field name] directly. Use selectedvalue( 'table'[fied name] ) or max( 'table'[fied name] ) replace "F2", so as function MONTH(),YEAR(). Selectedvalue() means return current row's value.

For example, i have one table named test.

ID start date end date
001 2/1/2022 2/15/2022
002 2/2/2022  
003 2/3/2022 2/16/2022

And measure

Measure =
IF(
    ISBLANK( SELECTEDVALUE( 'Table'[end date] ) ),
    IF(
        YEAR( SELECTEDVALUE( 'Table'[start date] ) ),
        ( - MONTH( SELECTEDVALUE( 'Table'[start date] ) + 12 ) ),
        1
    ),
    MONTH( SELECTEDVALUE( 'Table'[end date] ) ) / 12
)

 

vchenwuzmsft_0-1643790252978.png

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , This should work with column name in power bi

F(ISBLANK([F]);IF(YEAR([E])=2021;(-MONTH([E])+12)/12;1);MONTH([F])/12)

 

E and F should be date

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.