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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Excel formula to DAX Calculate column

Hi, 

The below is the Excel Formula Now I want to  convert into DAX Calculated column. Please Suggest on this one

IF [  "Date1" - MAX ( "Date2";" Date1";" Date3";"Date4") ] > 1  THEN "0" ELSE "1"

 

Thanks

3 REPLIES 3
tamerj1
Super User
Super User

Hi @Anonymous 

please try

=
VAR Date1 = [Date1]
VAR T1 =
    GENERATESERIES ( 1, 4, 1 )
VAR T2 =
    ADDCOLUMNS (
        T1,
        "@Date", SWITCH ( [Value], 1, [Date1], 2, [Date2], 3, [Date3], 4, [Date4] )
    )
VAR MaxDate =
    MAXX ( T2, [@Date] )
RETURN
    IF ( DATEDIFF ( MaxDate, Date1, DAY ) > 1, 1, 0 )
Anonymous
Not applicable

Hi Tamerj1,

 

When I am adding the above Dax Calculation in a new measure  I am not able to get the Table and column name date1. any suggetions Please

Baburao2123490_0-1661163020421.png

 

Hi @Anonymous 
For measure please try

=
VAR Date1 = [Date1]
VAR T1 =
    GENERATESERIES ( 1, 4, 1 )
VAR T2 =
    ADDCOLUMNS (
        T1,
        "@Date",
            SWITCH (
                [Value],
                1, MAX ( [Date1] ),
                2, MAX ( [Date2] ),
                3, MAX ( [Date3] ),
                4, MAX ( [Date4] )
            )
    )
VAR MaxDate =
    MAXX ( T2, [@Date] )
RETURN
    IF ( DATEDIFF ( MaxDate, Date1, DAY ) > 1, 1, 0 )

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.