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
POSPOS
Post Partisan
Post Partisan

Conditional columns using DAX in Power BI

HI All,

I have a requirement to display a new column based on a two other columns from the same table.

 

Scenario:

For each contract no., look for the minimum 'contract received date' and then display the respective 'contract executed date' in the new column.

 

Sample data:

Contract No.Contract Received dateContract Executed DateNew Column

22

7/7/20224/17/20234/17/2023

22

7/7/20224/17/20234/17/2023

22

8/7/20221/11/20224/17/2023

22

8/7/20221/11/20224/17/2023
2311/4/20237/8/20214/6/2021
2311/4/20237/8/2021 4/6/2021
232/9/20234/6/2021 4/6/2021
232/9/20234/6/2021 4/6/2021
245/8/20211/1/20211/1/2021
245/8/20211/1/20211/1/2021
249/9/20232/2/20221/1/2021
249/9/20232/2/20221/1/2021

 

Could someone please help with the DAX to achieve this result?

 

Thank you

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

and you can try this

DateNew2 = 
VAR t1 = 'Table'[Contract No.]
VAR t2 = ALLEXCEPT( 'Table', 'Table'[Contract No.] )
VAR t3 = CALCULATE( MIN( 'Table'[Contract Received date] ),t2  )
RETURN 
    CALCULATE(MIN('Table'[Contract Executed Date]),t2,
        'Table'[Contract No.] = t1 && 'Table'[Contract Received date] = t3
    )

View solution in original post

5 REPLIES 5
POSPOS
Post Partisan
Post Partisan

@Ahmedx  - thank you, both the solutions worked.

Ahmedx
Super User
Super User

and you can try this

DateNew2 = 
VAR t1 = 'Table'[Contract No.]
VAR t2 = ALLEXCEPT( 'Table', 'Table'[Contract No.] )
VAR t3 = CALCULATE( MIN( 'Table'[Contract Received date] ),t2  )
RETURN 
    CALCULATE(MIN('Table'[Contract Executed Date]),t2,
        'Table'[Contract No.] = t1 && 'Table'[Contract Received date] = t3
    )

sorry you can shorten the code further try this

 

DateNew2 = 
VAR t1 = 'Table'[Contract No.]
VAR t2 = ALLEXCEPT( 'Table', 'Table'[Contract No.] )
VAR t3 = CALCULATE( MIN( 'Table'[Contract Received date] ),t2  )
RETURN 
    CALCULATE(
        MIN('Table'[Contract Executed Date]),t2,
         'Table'[Contract Received date] = t3
    )

 

This worked too! thank you for the solution

Ahmedx
Super User
Super User

pls try this

DateNew = 
VAR t1 = 'Table'[Contract No.]
VAR t2 = CALCULATE( MIN( 'Table'[Contract Received date] ), ALLEXCEPT( 'Table', 'Table'[Contract No.] ) )
RETURN
    MINX(
        FILTER( ALL( 'Table' ), 'Table'[Contract No.] = t1 && 'Table'[Contract Received date] = t2 ),
        'Table'[Contract Executed Date]
    )

Screenshot_2.png

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.