Forum Discussion
Find Latest Transaction Date for Each Customer
- 10 years ago
I have successfully used LASTDATE.
Customer Last Transaction = LASTDATE('Sales'[OrderDate])
Then I populate the rows with the customer ID. My sales table is matched to my customer table using the ID.
- 10 years ago
heathernicole I have not read the whole post but give this a try...
Last Transaction = CALCULATE ( LASTDATE ( 'Sales Details'[SalesTxnTimeModified] ), ALLEXCEPT ( 'Customer', 'Customer'[Customer Name] ) ) - 10 years ago
Hello heathernicole! I don't know what to tell you???
I use this exact Measure to calculate Last Payment by Purchaser - and there are MANY MANY duplicate dates!
I just tried it and it works as a Calculated Column as well.
You know the May Update was released today - have you updated? (Even though this should not be the issue!)
https://powerbi.microsoft.com/en-us/blog/
- 10 years ago
heathernicole Try this...
Go to Modeling Tab => Click New Table button => type this...
Summary Table = SUMMARIZE ( 'Sales Details', 'Sales Details'[Customer ID], "Last Transaction", MAX ( 'Sales Details'[SalesTxnTimeModified] ) )
Well - I got the function to work - but it's not pull the proper data. The items grouped in red are the same customer. What it appears to be doing is pulling EACH transaction for the customer; NOT the LAST transaction. So I'm not sure what it's doing.
I've tried all of the suggestions from yesterday. None of them give errors but all of them are producing the same results it seems. I've also tried switching out MAX for LASTDATE.
Customer Last Transaction
Any ideas or thoughts about what might be the problem? I'm not sure what to do. I've tried using the LAST transaction date, the LAST salesTxnTime created, Time modified - I'm thinking it has to do with how Quickbooks handles data but I'm not entirely sure. arify Eric_Zhang - any thoughts or input you have is greatly appreciated! :)
heathernicole Are you using this as a measure or as a calculated column? I have one application of this where I add it as a calculated column in my customer table. that way is pulls a single date per customer from the sales fact table to the customer table. Perhaps this method would work for you?
- Sean10 years ago
Community Champion
heathernicole Try this...
Go to Modeling Tab => Click New Table button => type this...
Summary Table = SUMMARIZE ( 'Sales Details', 'Sales Details'[Customer ID], "Last Transaction", MAX ( 'Sales Details'[SalesTxnTimeModified] ) ) - Vvelarde10 years ago
Community Champion
Maybe using this:
Calculated Column
CustomerLastDateTransaction = CALCULATE(LASTDATE('Transaction'[TransactionDate]);ALLEXCEPT('Transaction';'Transaction'[CustomerName]))
- arify10 years ago
Microsoft Employee
Have you tried doing what I said to get latest date for each customer?
- Sean10 years ago
Community Champion
heathernicole I think you should stick to 'Sales Details' and 'Customer'
So you say they have a direct relationship based on Customer ID
'Sales Details' is on the MANY side * => 1 'Customer' on the 1 side of the relationship
Have you tried a table visualization with just these 2 items => Customer Name and Last Transaction (Measure)
Last Transaction = CALCULATE ( LASTDATE ( 'Sales Details'[SalesTxnTimeModified] ), ALLEXCEPT ( 'Customer', 'Customer'[Customer Name] ) ) - heathernicole10 years ago
Continued Contributor
Sean - I think that last solution may have worked! :)
I'm getting with the Sales Manager to double check the data, but from the looks of it - it looks correct!! :D
THANKS!!!!
EDIT. :) It's correct!!! Sean
THANK YOU SO MUCH! Now- I understand what I did, but I'm not exactly sure WHY it worked. Did separating them take care of some underlying filter? That's what I had originally perceived to be the problem is because of the structure it was causing some filtering underneath that I couldn't see right away.
Thoughts?
- Sean10 years ago
Community Champion
heathernicole Great! Glad you got it working!
As far as why it was not working - I don't know - your guess is as good as mine?
I really thought everything suggested in this post should have worked (including the Query Editor Group By)
I personally use the Measure I suggested - and my setup is prettry much same as yours... so go figure...
- heathernicole10 years ago
Continued Contributor
kcantor I am using a calculated column - not a measure. I wonder if a measure WOULD work better in this case. Although I'm not sure why it would.
- heathernicole10 years ago
Continued Contributor
Vvelarde - Hey! :) Sean I believe also suggested this or something similar.
However - I'm still getting the same results. The box in red is all the same customer. Also - the Cutomer, Transaction Date are in separate tables. I don't know if that makes a difference or not.
- Vvelarde10 years ago
Community Champion
Can share us the data model:
How many tables using for this and his relationship.
Customers
Transactions
anything else?
Tanks
- heathernicole10 years ago
Continued Contributor
Vvelarde Tables used in this report (Not able to show all columns)
Raw Data to work with if anyone wants it. I couldn't show customer Names though so I just did a count.
Transaction Age Customer Last Transaction Count of Customer Name Customer Status 330 7/7/2015 0:00 3919 11-Month Customer 882 1/1/2014 0:00 3919 13+ - Month Customer 877 1/6/2014 0:00 3919 13+ - Month Customer 876 1/7/2014 0:00 3919 13+ - Month Customer 875 1/8/2014 0:00 3919 13+ - Month Customer 874 1/9/2014 0:00 3919 13+ - Month Customer 873 1/10/2014 0:00 3919 13+ - Month Customer 870 1/13/2014 0:00 3919 13+ - Month Customer 869 1/14/2014 0:00 3919 13+ - Month Customer 868 1/15/2014 0:00 3919 13+ - Month Customer 867 1/16/2014 0:00 3919 13+ - Month Customer 866 1/17/2014 0:00 3919 13+ - Month Customer 863 1/20/2014 0:00 3919 13+ - Month Customer 862 1/21/2014 0:00 3919 13+ - Month Customer 861 1/22/2014 0:00 3919 13+ - Month Customer 860 1/23/2014 0:00 3919 13+ - Month Customer 859 1/24/2014 0:00 3919 13+ - Month Customer 856 1/27/2014 0:00 3919 13+ - Month Customer 855 1/28/2014 0:00 3919 13+ - Month Customer 854 1/29/2014 0:00 3919 13+ - Month Customer 853 1/30/2014 0:00 3919 13+ - Month Customer 852 1/31/2014 0:00 3919 13+ - Month Customer 849 2/3/2014 0:00 3919 13+ - Month Customer 848 2/4/2014 0:00 3919 13+ - Month Customer 847 2/5/2014 0:00 3919 13+ - Month Customer 846 2/6/2014 0:00 3919 13+ - Month Customer 845 2/7/2014 0:00 3919 13+ - Month Customer 842 2/10/2014 0:00 3919 13+ - Month Customer 841 2/11/2014 0:00 3919 13+ - Month Customer - Sean10 years ago
Community Champion
heathernicole what is the relationship between these 3 tables?
First you were using 'Sales Details' and 'Customer'
Now it seems you are using "Calendar - Transaction Date' and 'Customer'
Where is the Last Date you are looking for in 'Sales Details' or 'Calendar - Transaction Date'?
And how are these 3 tables related?
- Vvelarde10 years ago
Community Champion
Create the calculated column in Customers.
CustomerLastDateTransaction = CALCULATE(LASTDATE('Calendar-Transact'[TransactionDate]);ALLEXCEPT('Customer';'Customer'[CustomerAccount]))
Or
Created in Sales Details the calculated column should be:
CustomerLastDateTransaction = CALCULATE(LASTDATE('Calendar-Transact'[TransactionDate]);ALLEXCEPT('SalesDetails';'SalesDetails'[CustomerAccount]))
Please try and Feedback
- heathernicole10 years ago
Continued Contributor
Sean - I've tried a couple of different solutions.
The Sales Details has all transaction information - that was what I was originally using. When that wasn't producing the correct results I attempted the Calendar - Transaction Date Table which is linked to the Sales Details table.
Sales Details is linked to Customer table with a Customer ID Link and the Calendar Table.
The Calendar table is simply a lookup table.
Information, such as the Customer Name are in the Customer Table - NOT the Sales Details table but they are related to each other.
- heathernicole10 years ago
Continued Contributor
arify -Hey! :) Yes, I did try. But it wouldn't work because Customer and the Transaction Dates are in separate tables. Or at least I couldn't see a way to make it work. It didn't give me the option to select a different table in Group BY.
- arify10 years ago
Microsoft Employee
Doesn't Transaction Dates table have information of which customer made that transaction? If not, how did you create the tables in your screenshots? Did you join them?
You can merge those 2 tables in Query Editor (you can use the buttons)
- arify10 years ago
Microsoft Employee
@heathernicole Oh I see, they have a relationship. In that case, in the Query Editor, Customers table should have a Transaction Dates column created for this relation, and that column should have Tables or Records. You can expand that column (click the button on top right corner of the column, pick your date column in there). Then you should be able to do the Group By operation.
- heathernicole10 years ago
Continued Contributor
Sean Yes. It's a data module set up by QQube to work with Quickbooks data.
I've tired JUST using those two items. It cut down on the amount of "Last Transactions" per customer but it still won't just pull the most recent and ONLY the most recent. :/
- heathernicole10 years ago
Continued Contributor
Sean Just started working on this today - getting ready to try. :) Thanks for the suggestion!