cancel
Showing results for
Did you mean:
Highlighted
New Member

## Find the last trasaction per day, per customer

Hello All,

I have a dataset that captures multiple customers who update a quantity field several times a day, differentiated by a timestamp.

I need to be able to display by way of table or column or measure:

• the last record per day
• per customer
• and the associated quantity.

Dataset:

 Customer timestamp Qty Customer A 4/04/2020 11:07 0 Customer A 4/04/2020 16:24 1 Customer A 4/04/2020 20:03 1 Customer A 5/04/2020 8:17 2 Customer A 5/04/2020 10:53 2 Customer A 5/04/2020 12:29 2 Customer A 5/04/2020 13:18 2 Customer A 5/04/2020 16:53 2 Customer A 5/04/2020 19:59 3 Customer A 6/04/2020 8:51 3 Customer A 6/04/2020 9:56 1

Result (with additional customer for context)

 Customer timestamp Qty Customer A 4/04/2020 20:03 1 Customer A 5/04/2020 19:59 3 Customer A 6/04/2020 9:56 1 Customer B 6/04/2020 20:02 2 Customer B 7/04/2020 7:55 2

Any guidance would be much appreciated, many thanks all.

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Super User VI

## Re: Find the last trasaction per day, per customer

Is this a duplicate post?  In any case, this DAX expression for a calculated table will return your result from your example data.

``````Latest =
SUMMARIZE ( Qty, Qty[Customer], Qty[Date] ),
"@time", CALCULATE ( MAX ( Qty[timestamp] ) ),
"@Qty",
VAR maxtime =
CALCULATE ( MAX ( Qty[timestamp] ) )
RETURN
CALCULATE ( AVERAGE ( Qty[Qty] ), Qty[timestamp] = maxtime )
)``````

You can adapt it for use in a measure too, if needed.  You can store the above table in a variable, and then analyze it within the same measure.

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat

Did I answer your question? Please mark my post as a solution! Kudos are also appreciated!

Proud to be a Super User!

Highlighted
Super User V

## Re: Find the last trasaction per day, per customer

Hi,

You may download my solution workbook from here.

Hope this helps.

Regards,
Ashish Mathur
http://www.ashishmathur.com
2 REPLIES 2
Highlighted
Super User VI

## Re: Find the last trasaction per day, per customer

Is this a duplicate post?  In any case, this DAX expression for a calculated table will return your result from your example data.

``````Latest =
SUMMARIZE ( Qty, Qty[Customer], Qty[Date] ),
"@time", CALCULATE ( MAX ( Qty[timestamp] ) ),
"@Qty",
VAR maxtime =
CALCULATE ( MAX ( Qty[timestamp] ) )
RETURN
CALCULATE ( AVERAGE ( Qty[Qty] ), Qty[timestamp] = maxtime )
)``````

You can adapt it for use in a measure too, if needed.  You can store the above table in a variable, and then analyze it within the same measure.

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat

Did I answer your question? Please mark my post as a solution! Kudos are also appreciated!

Proud to be a Super User!

Highlighted
Super User V

## Re: Find the last trasaction per day, per customer

Hi,

You may download my solution workbook from here.

Hope this helps.

Regards,
Ashish Mathur
http://www.ashishmathur.com

Announcements

#### Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

#### Experience what’s next for Power BI

See the latest Power BI innovations, updates, and demos from the Microsoft Business Applications Launch Event.

#### Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

#### Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors