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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
powerbi_9
Frequent Visitor

Lookup value for date with 31 days

Hi,

 

I am fairly new to Power BI and trying to understand the DAX funtions. I am struck with the below. Any help is appreciated.

 

The request is to get the first status based on the start date in dataset2 where parent id matches and start date of data set2 is with in 31 days of startdate of dataset1

powerbisample.png

1 ACCEPTED SOLUTION

Hi @powerbi_9

 

You may refer to below dax to create the calculated columns and link the two table in relationship view.

date_outcome =
CALCULATE (
    FIRSTNONBLANK ( Table2[StartDate], 1 ),
    FILTER (
        Table2,
        Table2[StartDate] >= Table1[StartDate]
            && Table2[ParentID] = Table1[ParentID]
            && Table2[StartDate]
            < Table1[StartDate] + 31
    )
)
Status_lookup =
CALCULATE (
    FIRSTNONBLANK ( Table2[Status], 1 ),
    TOPN (
        1,
        FILTER (
            Table2,
            Table2[StartDate] = Table1[date_outcome]
                && Table2[ParentID] = Table1[ParentID]
        ),
        Table2[ChildID], ASC
    )
)

 

 1.png

Regards,

Cherie

Community Support Team _ Cherie Chen
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

3 REPLIES 3
powerbi_9
Frequent Visitor

Also, it is possible that both datasets may have the duplicate parent id's.

Hi @powerbi_9

 

You may refer to below dax to create the calculated columns and link the two table in relationship view.

date_outcome =
CALCULATE (
    FIRSTNONBLANK ( Table2[StartDate], 1 ),
    FILTER (
        Table2,
        Table2[StartDate] >= Table1[StartDate]
            && Table2[ParentID] = Table1[ParentID]
            && Table2[StartDate]
            < Table1[StartDate] + 31
    )
)
Status_lookup =
CALCULATE (
    FIRSTNONBLANK ( Table2[Status], 1 ),
    TOPN (
        1,
        FILTER (
            Table2,
            Table2[StartDate] = Table1[date_outcome]
                && Table2[ParentID] = Table1[ParentID]
        ),
        Table2[ChildID], ASC
    )
)

 

 1.png

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Worked perfectly. Thank you!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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