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

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

Reply
jasmith866
Helper I
Helper I

Extracting data from a FILTER() table based on data within the returned table

My dataset has a table of records representing completed tasks, and a separate table containing a log of 'history' events relating to those tasks. I am trying to extract, in a custom column for a given task, data from the history table that matches certain criteria.

 

Here's an example of what the history table looks like:

Parent RecordFieldCreated By Created TimeValue
132456789Field 1John10/10/2010 10:10VALUE A
132456789Field 1Jane12/12/2012 12:12VALUE A
132456789Field 2John14/02/2015 14:14VALUE C
132456789Field 2Jane18/04/2017 16:16VALUE D
132456789Field 3John21/06/2019 18:18VALUE E
132456789Field 4Jane23/08/2019 20:20VALUE F

 

The table contains a large number of rows, and on each row we have an identifier to link the history log back to the parent 'task' record that they relate to.

 

What I want to find for each task is:

The Name of the person who has an entry for a given field (say Field 1 in the example) with the earliest creation date

 

Here's what i've been working with so far:

CALCULATE(FIRSTNONBLANK('History Table'[CreatedBy],1),FILTER('History Table','History Table'[ParentId] = 'Task Table'[Id] && 'History Table'[Field] = "Field 1")

 

I wrote the above with the expectation that as the rows in the history table are in chronological order, the firstnonblank row would contain the earliest date. But i'm getting inconsistent results whereby the first row is not always selecting the earliest date - which suggests to me that the sorting on the returned table is not fixed and I can't find a resource anywhere which describes how the function works.

 

Looking for ideas/suggestions for how to tackle the problem. 1000 thanks in advance

1 ACCEPTED SOLUTION
v-xicai
Community Support
Community Support

Hi @jasmith866 ,

 

You may create measure like DAX below.

 

Measure1 =
VAR MinDate =
    CALCULATE (
        MIN ( 'History Table'[Created Time] ),
        FILTER (
            ALLSELECTED ( 'History Table' ),
            'History Table'[ParentId] = MAX ( 'History Table'[ParentId] )
                && 'History Table'[Field] = MAX ( 'History Table'[Field] )
                && 'History Table'[Created Time] < MAX ( 'History Table'[Created Time] )
        )
    )
RETURN
    CALCULATE (
        FIRSTNONBLANK ( 'History Table'[CreatedBy], 1 ),
        FILTER (
            'History Table',
            'History Table'[ParentId] = 'Task Table'[Id]
                && 'History Table'[Field] = "Field 1"
                && 'History Table'[Created Time] = MinDate
        )
    )

 

Best Regards,

Amy 

 

Community Support Team _ Amy

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

1 REPLY 1
v-xicai
Community Support
Community Support

Hi @jasmith866 ,

 

You may create measure like DAX below.

 

Measure1 =
VAR MinDate =
    CALCULATE (
        MIN ( 'History Table'[Created Time] ),
        FILTER (
            ALLSELECTED ( 'History Table' ),
            'History Table'[ParentId] = MAX ( 'History Table'[ParentId] )
                && 'History Table'[Field] = MAX ( 'History Table'[Field] )
                && 'History Table'[Created Time] < MAX ( 'History Table'[Created Time] )
        )
    )
RETURN
    CALCULATE (
        FIRSTNONBLANK ( 'History Table'[CreatedBy], 1 ),
        FILTER (
            'History Table',
            'History Table'[ParentId] = 'Task Table'[Id]
                && 'History Table'[Field] = "Field 1"
                && 'History Table'[Created Time] = MinDate
        )
    )

 

Best Regards,

Amy 

 

Community Support Team _ Amy

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

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.