This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreGet Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher 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.
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |