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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Nika777
Frequent Visitor

Please help, how to get the latest date out of multiple columns and display the respective column

Dear BI Community, I just entered the Power BI world and hope that I can find some help for my first steps.

I have a table:

ProjectStart DateMilestone 1Milestone 2Milestone 3Milestone 4
A1/1/20202/15/20207/27/20208/14/202110/23/2022
B5/3/20207/4/20218/18/20213/10/2022 
C12/12/20203/9/20218/15/2022  

 

I want to have a gantt view, where BI calculates the latest date of Milestones 1-4 and displays me the respective column name in the gantt view. So for Project A the latest date is Milestone 4, for Project B it is Milestone 3 and for Project C it is Milestone 2.

So I need in addition to the latest date calculation the ourput of which Milestone it is.

I hope I could describe my problem well enlugh and I am hoping, that someone could help me please.

Many thanks and have a great day

Nika

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @Nika777 ,

 

My approach would be to unpivot the milestone columnns and then either use measures or calculated columns to get the max date per project and the corresponding milestone.

danextian_0-1674087427629.png

 

Max Date Per Project = 
CALCULATE ( MAX ( MyData[Date] ), ALLEXCEPT ( MyData, MyData[Project] ) )

Max date per project (calc column) = 
CALCULATE ( MAX ( MyData[Date] ), ALLEXCEPT ( MyData, MyData[Project] ) )

Milestone with max date per project = 
CALCULATE (
    SELECTEDVALUE ( MyData[Milestone] ),
    FILTER (
        ALLEXCEPT ( MyData, MyData[Project] ),
        MyData[Date] = [Max Date Per Project]
    )
)

Milestone with max date per project (calc column) = 
CALCULATE (
    MAX ( MyData[Milestone] ),
    FILTER (
        ALL ( MyData ),
        MyData[Date] = EARLIER ( MyData[Max date per project (calc column)] )
            && MyData[Project] = EARLIER ( MyData[Project] )
    )
)

Please see attached pbix for your reference.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

2 REPLIES 2
danextian
Super User
Super User

Hi @Nika777 ,

 

My approach would be to unpivot the milestone columnns and then either use measures or calculated columns to get the max date per project and the corresponding milestone.

danextian_0-1674087427629.png

 

Max Date Per Project = 
CALCULATE ( MAX ( MyData[Date] ), ALLEXCEPT ( MyData, MyData[Project] ) )

Max date per project (calc column) = 
CALCULATE ( MAX ( MyData[Date] ), ALLEXCEPT ( MyData, MyData[Project] ) )

Milestone with max date per project = 
CALCULATE (
    SELECTEDVALUE ( MyData[Milestone] ),
    FILTER (
        ALLEXCEPT ( MyData, MyData[Project] ),
        MyData[Date] = [Max Date Per Project]
    )
)

Milestone with max date per project (calc column) = 
CALCULATE (
    MAX ( MyData[Milestone] ),
    FILTER (
        ALL ( MyData ),
        MyData[Date] = EARLIER ( MyData[Max date per project (calc column)] )
            && MyData[Project] = EARLIER ( MyData[Project] )
    )
)

Please see attached pbix for your reference.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Dear Danextian,

oh very cool, many thanks. As I need to keep the dates in one horizontal row (instead of columns) I could not apply this directly, but your approach helped me to transfer this to the horizontal in MS Excel first and then to transfer it to Power BI to make the visualizations. So many many thanks for this quick help 🙂

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.

Top Solution Authors
Top Kudoed Authors