Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Good afternoon.
I need help creating a calculated column that returns the customer's previous payment amount.
example. Line 1 of the image below.
For the customer abc123, the value of the first must bring in a new column the value of 40 (referring to the payment made on 2021-10-05)
if there is no previous payment show empty
Link download do pbix.
https://drive.google.com/file/d/1Sw5hZGNfZyK5_xz8C4yR2yQiwGun3z66/view?usp=sharing
Thanks if anyone can take the time to hel
Solved! Go to Solution.
Hi @RSSILVA_22
if you're looking for a calculated column then please try
Previous Payment =
VAR CurrentDate = 'Table'[payment date]
VAR CurrentTable =
CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[cod_client] ) )
VAR TableBefore =
FILTER ( CurrentTable, 'Table'[payment date] < CurrentDate )
VAR PreviousRecord =
TOPN ( 1, TableBefore, 'Table'[payment date] )
RETURN
MAXX ( PreviousRecord, 'Table'[value] )
Hi @RSSILVA_22
if you're looking for a calculated column then please try
Previous Payment =
VAR CurrentDate = 'Table'[payment date]
VAR CurrentTable =
CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[cod_client] ) )
VAR TableBefore =
FILTER ( CurrentTable, 'Table'[payment date] < CurrentDate )
VAR PreviousRecord =
TOPN ( 1, TableBefore, 'Table'[payment date] )
RETURN
MAXX ( PreviousRecord, 'Table'[value] )
very good
thanks.
Use the following code...
Previous Value Total = VAR currentDate = SELECTEDVALUE('pratic'[payment date])
VAR previousDate = MAXX(FILTER(ALL('pratic'),pratic[payment date]<currentDate && 'pratic'[cod_client]=MAX('pratic'[cod_client])),'pratic'[payment date])
RETURN
IF(ISINSCOPE('pratic'[cod_client]),
CALCULATE([Value Total],FILTER(ALLSELECTED('pratic'),previousDate='pratic'[payment date]))
,[Value Total])
You could also use the following to check if PaymentDate is being used and default the value to Total if not...
Previous Value Total = VAR currentDate = SELECTEDVALUE('pratic'[payment date])
VAR previousDate = MAXX(FILTER(ALL('pratic'),pratic[payment date]<currentDate && 'pratic'[cod_client]=MAX('pratic'[cod_client])),'pratic'[payment date])
RETURN
SWITCH(TRUE()
,AND(ISINSCOPE('pratic'[cod_client]),(ISINSCOPE(pratic[payment date]))), CALCULATE([Value Total],FILTER(ALLSELECTED('pratic'),previousDate='pratic'[payment date]))
,AND(ISINSCOPE('pratic'[cod_client]),NOT(ISINSCOPE(pratic[payment date]))),[Value Total]
,[Value Total])
Thanks for the feedback.
Very good instructions.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 6 | |
| 5 | |
| 5 | |
| 4 |
| User | Count |
|---|---|
| 25 | |
| 16 | |
| 8 | |
| 7 | |
| 7 |