Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
47 | |
22 | |
20 | |
15 | |
13 |
User | Count |
---|---|
49 | |
41 | |
39 | |
19 | |
19 |