Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Thorgi
Regular Visitor

Direct query > sum of sale, after customer buys promotion product

Hello everyone,

 

I am using direct query and looking to calculate running total of sale after customer purchases promotional product the first time (customer is allowed to purchase promotional product again at later date).

Below is similar to table I have.

CustomerDatePromoSales
11/1/2019  $        50.00
11/3/2019a $               -  
22/4/2019  $   2,415.00
22/7/2019a $               -  
13/11/2019  $   2,152.00
23/31/2019  $   2,341.00
13/31/2019a $               -  
23/31/2019a $               -  
14/1/2019  $      435.00
24/3/2019  $   5,334.00
15/23/2019  $      754.00

 

I would like the result to show $3,341 for customer 1 and $7,675 for customer 2 (total sale after customers buys promo product 'a' first time). I am also looking to add summary KPI visual to show overall customers (in this example $11,016).

 

Any help would be greatly appreciated.

Have a wonderful day.

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @Thorgi ,

 

Please refer to below measures:

first time pur =
CALCULATE (
    MIN ( Sheet6[Date] ),
    FILTER ( ALLEXCEPT ( Sheet6, Sheet6[Customer] ), Sheet6[Promo] <> BLANK () )
)

running total =
CALCULATE (
    SUM ( Sheet6[Sales] ),
    FILTER (
        ALLEXCEPT ( Sheet6, Sheet6[Customer] ),
        Sheet6[Date] <= MAX ( Sheet6[Date] )
            && Sheet6[Date] >= [first time pur]
    )
)

1.PNG

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yulgu-msft
Employee
Employee

Hi @Thorgi ,

 

Please refer to below measures:

first time pur =
CALCULATE (
    MIN ( Sheet6[Date] ),
    FILTER ( ALLEXCEPT ( Sheet6, Sheet6[Customer] ), Sheet6[Promo] <> BLANK () )
)

running total =
CALCULATE (
    SUM ( Sheet6[Sales] ),
    FILTER (
        ALLEXCEPT ( Sheet6, Sheet6[Customer] ),
        Sheet6[Date] <= MAX ( Sheet6[Date] )
            && Sheet6[Date] >= [first time pur]
    )
)

1.PNG

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.