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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Converting Tableau function into Power BI DAX

IF LOOKUP(MIN([ID]),0) = LOOKUP(MIN([ID]),-1)

THEN DATEDIFF('day',LOOKUP(MIN([Date]), -1), LOOKUP(MIN([Date]), 0))
END

Need to convert this Tableau function into DAX, I have attaced sample data for your reference. image.png
1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community Support

Hi @Anonymous ,

 

According to your description, refer to the following formula whether to meet your going:

col_new =
VAR _max =
    CALCULATE (
        MAX ( 'Table'[Date] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[ID] = EARLIER ( 'Table'[ID] )
                && 'Table'[Date] < EARLIER ( 'Table'[Date] )
        )
    )
RETURN
    DATEDIFF ( _max, 'Table'[Date], DAY )

vhenrykmstf_0-1645166569157.png


If the problem is still not resolved, please point it out. Looking forward to your reply.


Best Regards,
Henry


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

 

View solution in original post

2 REPLIES 2
v-henryk-mstf
Community Support
Community Support

Hi @Anonymous ,

 

According to your description, refer to the following formula whether to meet your going:

col_new =
VAR _max =
    CALCULATE (
        MAX ( 'Table'[Date] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[ID] = EARLIER ( 'Table'[ID] )
                && 'Table'[Date] < EARLIER ( 'Table'[Date] )
        )
    )
RETURN
    DATEDIFF ( _max, 'Table'[Date], DAY )

vhenrykmstf_0-1645166569157.png


If the problem is still not resolved, please point it out. Looking forward to your reply.


Best Regards,
Henry


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 , a new column

var _max = maxx(filter(Table, [ID] = earlier([ID]) && [Date] < earlier([Date]) ), [Date])

return

datediff(_max, [Date], day)

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.