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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
thibbos
Resolver I
Resolver I

Create New Table with only the last sale per product and per customer

Hi there,

 

I have a table that contains lots of rows per customer, per product, per date and the sale of it.

Every customer could order the same product every month, so basically I have twelve different sales date per customer/per product.

 

Now I wanted to calculated the sum of sales for all the MAX date for that product and that customer. In order to do that I created a new table SUMMARIZING per product/customer/latest date ... Now the issue I have is that for the sales, it only seems to give me a sum of all sales.

 

I want a new table so that I can add up the total for all products and customers (that's what I needed). I hgave tried with a measure but somehow it doesn't give me actual results

Thanks a lot everyone

see example:

ACTUAL TABLE
CustomerProductDateSale
A1Jan-20100
A1Sep-20200
A2Mar-20300
A2Dec-20400
    
DESIRED TABLE
CustomerProductDateSale
A1Sep-20200
A2Dec-20400
1 ACCEPTED SOLUTION
v-deddai1-msft
Community Support
Community Support

Hi @thibbos ,

 

You can use the following measure:

Table1 =
ADDCOLUMNS (
    SUMMARIZE (
        'Table',
        'Table'[Customer],
        'Table'[Product],
        "Date", MAX ( 'Table'[Date] )
    ),
    "sales",
        CALCULATE (
            SUM ( 'Table'[Sale] ),
            FILTER ( 'Table', 'Table'[Date] = EARLIER ( [Date] ) )
        )
)

Capture.PNG

 

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

 

Best Regards,

Dedmon Dai

 

View solution in original post

2 REPLIES 2
thibbos
Resolver I
Resolver I

Hi @v-deddai1-msft  , thanks for the proposition. Sorry for not answering sooner but I moved to another issue.

I will look at it in time and mark it as a solution when I have the chance to check it out.

 

BR

Thibault

v-deddai1-msft
Community Support
Community Support

Hi @thibbos ,

 

You can use the following measure:

Table1 =
ADDCOLUMNS (
    SUMMARIZE (
        'Table',
        'Table'[Customer],
        'Table'[Product],
        "Date", MAX ( 'Table'[Date] )
    ),
    "sales",
        CALCULATE (
            SUM ( 'Table'[Sale] ),
            FILTER ( 'Table', 'Table'[Date] = EARLIER ( [Date] ) )
        )
)

Capture.PNG

 

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

 

Best Regards,

Dedmon Dai

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.