Forum Discussion

pwe5000's avatar
pwe5000
Frequent Visitor
4 years ago
Solved

EARLIER function does not recognize my column names

Hello! I've looked for an answer to this all over the place, and I can't find anyone directly addressing it.   In the Microsoft DAX documentation, it gives this example for the EARLIER function:  ...
  • v-yanjiang-msft's avatar
    4 years ago

    Hi pwe5000 ,

    EARLIER will return the current value in a calculated column, not a measure. In a measure, MAX/MIN/SUM can return the current value.

    According to your description, I create a sample. I create a calculated column by your formula, it calculates the number of SalesOrders that are the same as the current SalesOrder.

    If you want to filter out all duplicates, here's my solution.

    1.Add a index column in Power Query.

    2.Create a calculated column.

    Rank = 
    RANKX (
        FILTER (
            'Hobart Sales on Ebay',
            'Hobart Sales on Ebay'[SalesOrder]
                = EARLIER ( 'Hobart Sales on Ebay'[SalesOrder] )
        ),
        'Hobart Sales on Ebay'[Index],
        ,
        ASC,
        DENSE
    )

    Get this table.

     

    3.By selecting Rank is 1, it will filter out all duplicates.

    I attach my sample below for reference.

     

    Best Regards,
    Community Support Team _ kalyj

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