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
JKVM
New Member

Get last orderdate per product per customer

I have a basic order table with many different products. I would like to generate an overview for the last orderdate per customer per product. Cannot succeed in finding the right formula. Max formula only retrieves max of one value. Should I generate a new table for this or should I do that in the orderoverview table. Risking that for every orderline again, the max value needs to be calculated.

Please advise both on the best approach and the formula to use.

CustomerIDProductIDOrderDate
111-1-2022
1231-12-2021
1325-7-2022
2115-2-2022
2112-7-2022
213-8-2022
313-8-2021
3128-2-2022
325-7-2021
321-11-2021
321-4-2022
331-6-2021
411-7-2022
421-8-2022
431-9-2022
2 ACCEPTED SOLUTIONS
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a new table.

Jihwan_Kim_0-1673277004771.png

 

Jihwan_Kim_1-1673277170442.png

 

 

Last order date per customer and per product =
ADDCOLUMNS (
    SUMMARIZE ( Data, Customer[CustomerID], 'Product'[ProductID] ),
    "@maxdate", CALCULATE ( MAX ( Data[OrderDate] ) )
)

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

FreemanZ
Super User
Super User

hi @JKVM

In addition to Jihwan's solution, if you have all the columns in one table, you may also write a table like this:
LastTable = 
ADDCOLUMNS(
    SUMMARIZE(
        TableName, 
        TableName[CustomerID],
        TableName[ProductID]
    ),
    "LatestOrderDate",
    CALCULATE(MAX(TableName[OrderDate]))
)

Or you can simply plot a table visual with [CustomerID] column, [ProductID] column and a measure like this:
LatestOrderDate2 = MAX(TableName[OrderDate])

FreemanZ_3-1673279673298.png

 

 

View solution in original post

2 REPLIES 2
FreemanZ
Super User
Super User

hi @JKVM

In addition to Jihwan's solution, if you have all the columns in one table, you may also write a table like this:
LastTable = 
ADDCOLUMNS(
    SUMMARIZE(
        TableName, 
        TableName[CustomerID],
        TableName[ProductID]
    ),
    "LatestOrderDate",
    CALCULATE(MAX(TableName[OrderDate]))
)

Or you can simply plot a table visual with [CustomerID] column, [ProductID] column and a measure like this:
LatestOrderDate2 = MAX(TableName[OrderDate])

FreemanZ_3-1673279673298.png

 

 

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a new table.

Jihwan_Kim_0-1673277004771.png

 

Jihwan_Kim_1-1673277170442.png

 

 

Last order date per customer and per product =
ADDCOLUMNS (
    SUMMARIZE ( Data, Customer[CustomerID], 'Product'[ProductID] ),
    "@maxdate", CALCULATE ( MAX ( Data[OrderDate] ) )
)

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


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.

Top Solution Authors