Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Ranking

Hi all,   I'm trying to rank each customer's purchases chronologically based on their purchase date starting with "1" for each customer's first purchase and then sequencing numercially with each ad...
  • Jihwan_Kim's avatar
    4 years ago

    Hi,

    Please check the below picture and the attached pbix file.

     

     

    Rank invoicenumber base measure: = 
    RANKX (
        FILTER (
            ALL ( ep_Sales_Invoice_Line ),
            ep_Sales_Invoice_Line[Customer_Account_Number]
                = MAX ( ep_Sales_Invoice_Line[Customer_Account_Number] )
        ),
        CALCULATE ( MAX ( ep_Sales_Invoice_Line[INVOICENUMBER] ) ),
        ,
        ASC
    )

     

    Rank invoicedate base measure: = 
    RANKX (
        FILTER (
            ALL ( ep_Sales_Invoice_Line ),
            ep_Sales_Invoice_Line[Customer_Account_Number]
                = MAX ( ep_Sales_Invoice_Line[Customer_Account_Number] )
        ),
        CALCULATE ( MAX ( ep_Sales_Invoice_Line[Invoice_Date] ) ),
        ,
        ASC
    )

     

    Rank measure: =
    RANKX (
        FILTER (
            ALL ( ep_Sales_Invoice_Line ),
            ep_Sales_Invoice_Line[Customer_Account_Number]
                = MAX ( ep_Sales_Invoice_Line[Customer_Account_Number] )
        ),
        [Rank invoicedate base measure:] + [Rank invoicenumber base measure:] / 100,
        ,
        ASC
    )