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

Get Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.

Reply
ChrisPfP
Regular Visitor

find value at calculated date

I need to find a value based on a calculated date - ie what was [NewValue] on the first instance it was one of "Put it Right", "Stage 1" , "Stage 2" or "Stage 3". This is the measure I'm using to find the date but I can't work out how to show the [NewValue] (it's easy in SQL 

ChrisPfP_0-1655204338879.png

 

:

 

FirstStageDate =

var current_row_ParentId = min('History: Complaint'[ParentId])
var current_row_NewValue = min('History: Complaint'[NewValue])

var earliest_stage =
CALCULATE(
min('History: Complaint'[CreatedDate]),
FILTER(
ALLEXCEPT('History: Complaint','History: Complaint'[ParentId]),
'History: Complaint'[NewValue] = "Put it Right" || 'History: Complaint'[NewValue] = "Stage 1" || 'History: Complaint'[NewValue] = "Stage 2" || 'History: Complaint'[NewValue] = "Stage 3"
)
) return

earliest_stage

1 ACCEPTED SOLUTION
tamerj1
Community Champion
Community Champion

@ChrisPfP 

Please try

FirstStageDate =
VAR CurrentIDTable =
    CALCULATETABLE (
        'History: Complaint',
        ALLEXCEPT ( 'History: Complaint', 'History: Complaint'[ParentId] )
    )
VAR FilteredTable =
    FILTER (
        CurrentIDTable,
        'History: Complaint'[NewValue] = "Put it Right"
            || 'History: Complaint'[NewValue] = "Stage 1"
            || 'History: Complaint'[NewValue] = "Stage 2"
            || 'History: Complaint'[NewValue] = "Stage 3"
    )
VAR MinDate =
    MINX ( FilteredTable, 'History: Complaint'[CreatedDate] )
RETURN
    MAXX (
        FILTER ( FilteredTable, 'History: Complaint'[CreatedDate] = MinDate ),
        'History: Complaint'[Value]
    )

View solution in original post

7 REPLIES 7
johnt75
Super User
Super User

You can try

Value at earliest stage =
VAR summaryTable =
    TOPN (
        1,
        FILTER (
            ALLEXCEPT ( 'History: Complaint', 'History: Complaint'[ParentId] ),
            TREATAS (
                { "Put it Right", "Stage 1", "Stage 2", "Stage 3" },
                'History: Complaint'[NewValue]
            )
        ),
        'History: Complaint'[CreatedDate]
    )
RETURN
    SELECTCOLUMNS ( summaryTable, [NewValue] )

Thanks but I'm getting an error message 

ChrisPfP_0-1655213002957.png

 

What's the definition of Account[Case Owner] ?

Sorry I have no idea how that field got into the DAX!

tamerj1
Community Champion
Community Champion

Hi @ChrisPfP 
Please try

FirstStageDate =
CALCULATE (
    MIN ( 'History: Complaint'[CreatedDate] ),
    ALLEXCEPT ( 'History: Complaint', 'History: Complaint'[ParentId] ),
    FILTER (
        'History: Complaint',
        'History: Complaint'[NewValue] = "Put it Right"
            || 'History: Complaint'[NewValue] = "Stage 1"
            || 'History: Complaint'[NewValue] = "Stage 2"
            || 'History: Complaint'[NewValue] = "Stage 3"
    )
)

Thanks but this isn't showing me the [NewValue] value that I need to see

tamerj1
Community Champion
Community Champion

@ChrisPfP 

Please try

FirstStageDate =
VAR CurrentIDTable =
    CALCULATETABLE (
        'History: Complaint',
        ALLEXCEPT ( 'History: Complaint', 'History: Complaint'[ParentId] )
    )
VAR FilteredTable =
    FILTER (
        CurrentIDTable,
        'History: Complaint'[NewValue] = "Put it Right"
            || 'History: Complaint'[NewValue] = "Stage 1"
            || 'History: Complaint'[NewValue] = "Stage 2"
            || 'History: Complaint'[NewValue] = "Stage 3"
    )
VAR MinDate =
    MINX ( FilteredTable, 'History: Complaint'[CreatedDate] )
RETURN
    MAXX (
        FILTER ( FilteredTable, 'History: Complaint'[CreatedDate] = MinDate ),
        'History: Complaint'[Value]
    )

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.