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:

 

ProductSubcategoryKeyEnglishProductSubcategoryName TotalSubcategorySales SubcategoryRanking
18Bib-Shorts$156,167.8818
26Bike Racks$220,720.7014
27Bike Stands$35,628.6930
28Bottles and Cages$59,342.4324
5Bottom Brackets$48,643.4727

 

= COUNTROWS(FILTER(ProductSubcategory, EARLIER(ProductSubcategory[TotalSubcategorySales])<ProductSubcategory[TotalSubcategorySales]))+1

 

In trying to apply this to my use case, I get an error telling me that my column name isn't recognized:

 

The SalesOrder column is not a calculated column or a measure, but a column imported from my data source.

  • 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.

     

3 Replies

    • pwe5000's avatar
      pwe5000
      Frequent Visitor

      Hi parry2k,

       

      Good point! It's also possible that there's a more effective way to do this: I want this measure to identify duplicates in the SalesOrder column. I don't want to remove the duplicates completely, but I do want to be able to use this new column to filter out all duplicates in the SalesOrder column (i.e. not keeping one copy of each duplicate).

  • 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.