Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Dear Friends,
Please help me, i want to locate previous transaction : date & location.
here is the data :
ID CUSTOMER | TRANSACTION DATE | LOCATION |
AB123 | 1/1/2022 | B |
AB123 | 1/7/2022 | A |
AC344 | 1/4/2022 | B |
AC344 | 1/5/2022 | B |
AC344 | 1/18/2022 | B |
AC344 | 1/29/2022 | A |
AF789 | 1/4/2022 | B |
AF789 | 1/17/2022 | A |
AF789 | 1/19/2022 | B |
here is output that i want :
ID Customer | previous transaction date | Location Previous transaction |
AB123 | 1/1/2022 | B |
AC344 | 1/18/2022 | B |
AF789 | 1/17/2022 | A |
I prefer to use DAX command, because i use live connection.
Thanks for help
Solved! Go to Solution.
@ade_kurniawan hey, check this for my vesrion.
Is that what you need?
Transaction Customer v4.pbix
Thanks for help @SpartaBI & @CNENFRNL but i have another problem :
my data is in different table & i cant use variable that hide in table : PBI separated table
thanks
@ade_kurniawan hey, check this for my vesrion.
Is that what you need?
Transaction Customer v4.pbix
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 still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
@ade_kurniawan create these measures:
Previous transaction date =
VAR _current_date = MAX(Sheet1[TRANSACTION DATE])
VAR _current_id = SELECTEDVALUE(Sheet1[ID CUSTOMER])
RETURN
CALCULATE(
MAX(Sheet1[TRANSACTION DATE]),
REMOVEFILTERS(Sheet1),
Sheet1[ID CUSTOMER] = _current_id,
Sheet1[TRANSACTION DATE] < _current_date
)
Location of Previous transaction date =
VAR _current_date = MAX(Sheet1[TRANSACTION DATE])
VAR _current_id = SELECTEDVALUE(Sheet1[ID CUSTOMER])
VAR _previous_transaction_date =
CALCULATE(
MAX(Sheet1[TRANSACTION DATE]),
REMOVEFILTERS(Sheet1),
Sheet1[ID CUSTOMER] = _current_id,
Sheet1[TRANSACTION DATE] < _current_date
)
RETURN
CALCULATE(
SELECTEDVALUE(Sheet1[LOCATION]),
REMOVEFILTERS(Sheet1),
Sheet1[ID CUSTOMER] = _current_id,
Sheet1[TRANSACTION DATE] = _previous_transaction_date
)
Put them next to the ones you already have in the table.
You need to also put the current transaction data in the visual for it to work. Previous need to be previous to something:
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
13 | |
12 | |
11 | |
7 | |
7 |
User | Count |
---|---|
15 | |
13 | |
12 | |
9 | |
9 |