Calculate the sales amount from earliest date for same customerID with multiple orderdate

Hello @aedniranao,

Thank You for posting your query onto the Forum.

Is this the kind of result you’re looking for? Below is the screenshot of the result provided for the reference -

In order to achieve the provided result, below are the two measures written as follows -

Sales on First Order Date = 
VAR _Current_Extern_ID = 
SELECTEDVALUE( Orders[Externid] )

VAR _First_Order_Date =
MINX(
    FILTER( ALL( Orders ) , 
        Orders[Externid] = _Current_Extern_ID ) ,
    Orders[orderdate] )

VAR _First_Sales_Occurence =
CALCULATE( 
    FIRSTNONBLANKVALUE( Orders[orderdate] , 
        CALCULATE(
            SUMX( Orders , Orders[Net Sales] ) , 
                FILTER( Orders , 
                    Orders[Order Types] = 1 ) ,
                FILTER( Orders , 
                    Orders[salechannel] = 12 ) , 
                FILTER( 'Extern ID' , 
                    'Extern ID'[Count] > 3 ) ) ) , 
                ALLEXCEPT( Orders , 
                     Orders[Externid] ) )

VAR _Results =
IF( SELECTEDVALUE( Orders[orderdate] ) = _First_Order_Date , 
    _First_Sales_Occurence , 
    " " )

RETURN
_Results



Sales on First Order Date - Totals = 
SUMX(
    SUMMARIZE(
        Orders , 
        Orders[orderdate] , 
        'Extern ID'[Externid] , 
        "@Totals" , 
        [Sales on First Order Date] ) , 
    [@Totals]
)

I’m also attaching the working of the PBIX file for the reference purposes.

Hoping you find this useful and meets your requirements that you’ve been looking for. :slightly_smiling_face:

Thanks and Warm Regards,
Harsh

Example - Harsh.pbix (180.8 KB)

1 Like