Forum Discussion

DBrito79's avatar
DBrito79
Frequent Visitor
2 years ago
Solved

Find first values per earliest Date

Hello,
I have a table called "Cycles" and i need a dax column with the value (the name) of CYCLES[Status Atual] for the earlier/maximum [FirstMatingDate] and for each CYCLES[ID&FARM]


I am trying this formula:

EarliestStatusAtFirstMatingDate =
CALCULATEMAXX(
FILTERALL(CYCLES),
CYCLES[FirstMatingDate] = CALCULATEMAX(CYCLES[FirstMatingDate]),
ALLEXCEPT(CYCLES, CYCLES[ID&FARM])
)),
CYCLES[Status Atual]
)))

 

But it returns the me the status name with the last alfabethical order.

Can you help me with this?
Thanks in advance

  • Anonymous's avatar
    Anonymous
    2 years ago

    HI DBrito79,

    You can try to use the following measure formula if it suitable for your requirement:

    EarliestStatusAtFirstMatingDate =
    VAR _lastDate =
        CALCULATE (
            MAX ( CYCLES[FirstMatingDate] ),
            ALLSELECTED ( CYCLES ),
            VALUES ( CYCLES[ID&FARM] )
        )
    RETURN
        CALCULATE (
            MAX ( CYCLES[Status Atual] ),
            FILTER ( ALLSELECTED ( CYCLES ), CYCLES[FirstMatingDate] = _lastDate )
        )

    Regards,

    Xiaoxin Sheng

3 Replies