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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

lookup nearest date

Table 1
Name Date in ServiceFirst ProjectSecond Project
Alex K1-1-2018I want here the first project  of Table 2 of Alex K based on project start date vs Date In serviceHere  the second
Jay kay1-2-2018  
Bernd leo1-3-2018  
    
Table 2
Name name ProjectProject Start DateProject End Date
Alex KAA technology2-1-201814-2-2018
Alex KAB technology15-2-201811-3-2018
Alex KAC technology12-3-201814-2-2018
Jay kayAA technology15-2-201819-2-2018
Jay kayAB technology20-2-201811-3-2018
Jay kayAC technology12-3-201814-4-2018
Jay kayAD technology15-4-20181-3-2018
Bernd leoAA technology2-3-201811-3-2018
Bernd leoAB technology12-3-201814-3-2018
Bernd leoAC technology15-3-2018 

 

i have 2 tables and in table one i want to  have the first and scond project of table 2 based on the nearest Project start date in comparison with the date in service

example: Alex K first project is AA technology because 2-1-2018 is the first nearest date tot the date in service 1-1-2018

 

kind regards

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Thank so much! 

I also need the start date of the first and second project.

Can you help me with it?

View solution in original post

@Anonymous

 

Try with these.

 

Date First Project =
CALCULATE (
    MIN ( Table2[Project Start Date] ),
    FILTER (
        CALCULATETABLE ( VALUES ( Table2 ) ),
        Table2[Project Start Date] >= Table1[Date in Service]
    )
)
Date Second Project =
CALCULATE (
    MIN ( Table2[Project Start Date] ),
    FILTER (
        CALCULATETABLE ( VALUES ( Table2 ) ),
        Table2[Project Start Date] >= Table1[Date in Service]
    ),
    Table2[name Project] <> FirstProject
)

Regards
Zubair

Please try my custom visuals

View solution in original post

4 REPLIES 4
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous

 

Try these calculated columns

 

First Project =
VAR mydate =
    CALCULATE (
        MIN ( Table2[Project Start Date] ),
        FILTER (
            CALCULATETABLE ( VALUES ( Table2 ) ),
            Table2[Project Start Date] >= Table1[Date in Service]
        )
    )
RETURN
    CALCULATE (
        MIN ( Table2[name Project] ),
        FILTER (
            CALCULATETABLE ( VALUES ( Table2 ) ),
            Table2[Project Start Date] = mydate
        )
    )

Regards
Zubair

Please try my custom visuals

@Anonymous

 

Second Project =
VAR FirstProject = Table1[First Project]
VAR mydate =
    CALCULATE (
        MIN ( Table2[Project Start Date] ),
        FILTER (
            CALCULATETABLE ( VALUES ( Table2 ) ),
            Table2[Project Start Date] >= Table1[Date in Service]
        ),
        Table2[name Project] <> FirstProject
    )
RETURN
    CALCULATE ( MAX ( Table2[name Project] ), Table2[Project Start Date] = mydate )

Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

Thank so much! 

I also need the start date of the first and second project.

Can you help me with it?

@Anonymous

 

Try with these.

 

Date First Project =
CALCULATE (
    MIN ( Table2[Project Start Date] ),
    FILTER (
        CALCULATETABLE ( VALUES ( Table2 ) ),
        Table2[Project Start Date] >= Table1[Date in Service]
    )
)
Date Second Project =
CALCULATE (
    MIN ( Table2[Project Start Date] ),
    FILTER (
        CALCULATETABLE ( VALUES ( Table2 ) ),
        Table2[Project Start Date] >= Table1[Date in Service]
    ),
    Table2[name Project] <> FirstProject
)

Regards
Zubair

Please try my custom visuals

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.