cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Gekko1
Frequent Visitor

Value of last transaction

My problem is: I have a table of transactions and the date when those transactions ocurred; I'm looking for a way to get the las transaction value that ocurred prior to the last day of the month and year selected in the slicers. 

AccountIDCompanyIDValueDate
1A1002021-10-01
2A2002022-09-15
3A3002022-07-04
4B4002021-01-02
1A5002022-03-15
2A6002022-05-25
2A7002022-06-30
3A8002022-01-13

Example: If I select the year 2022 and the month MAY in slicers, the measure will return 500 to the Account 1; 600 to the Account; 800 to the Account 3, because those were the values of the last transactions that ocurred prior to the last day of the month selected (May, its last day is 2022-05-31).

1 ACCEPTED SOLUTION
CNENFRNL
Super User
Super User

CNENFRNL_0-1664910850742.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

5 REPLIES 5
CNENFRNL
Super User
Super User

CNENFRNL_0-1664910850742.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is beyond their comprehension!

DAX is simple, but NOT EASY!

It works only if I turn off the relationship between the DATA table and the DATES table, but if I do that, when I check the month slicer for a month that hasnt been closed yet (in my case october,2022) the measure no longer works.

amitchandak
Super User
Super User

@Gekko1 , Try these two

 

Last Value =
var _max1 = maxx(allselected(Data), Data[Date])
Var _max = maxx(filter( all(Data1), Data1[AccountID] = max(Data1[AccountID]) && Data1[Date]<= _max1 ),Data1[Date])
return
CALCULATE(sum(Data1[Value]), filter( (Data1), Data1[ID] = max(Data1[ID]) && Data1[Date] =_max))


Sum Last Value = sumx(VALUES(Data1[ID]) , [Last Value])

 

Second one is used to sum the first one

It didn't work. The issue that I'm having now is that if the last transaction of an account happened last month, it isnt shown. For example: the last transaction of a specific account happened in september 30th, but if I check the slicer box for october this year, no transactions are shown for that account.

In the variable _max1, the table data is supposed to be calendar table?

Helpful resources

Announcements
November 2022 Update

Check it Out!

Click here to read more about the November 2022 updates!

Microsoft 365 Conference â__ December 6-8, 2022

Microsoft 365 Conference - 06-08 December

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Solution Authors