Forum Discussion
shanipowerbi
Helper III
6 years agoSecond Last Invoice Amount
Hi Experts I need your help to calculate second last invoice amount. I have two table that contain 1 - Invoive Data Invoice ID / User ID / Invoice Amount / Invoice Date 2 - User Profiling D...
- 6 years ago
I believe you are trying to create a column.
This should work.
2ND Last Invoice Amount =
VAR LAST_DATE =
LASTDATE ( Invoice[Invoice Date] )
VAR PREVIOUS_DATE =
CALCULATE (
MAX ( Invoice[Invoice Date] ),
FILTER ( ALL ( Invoice[Invoice Date] ), Invoice[Invoice Date] < LAST_DATE )
)
RETURN
CALCULATE (
SUM ( Invoice[Invoice Amt] ),
Invoice[Invoice Date] = PREVIOUS_DATE
)If it helps mark it as a solution.
Kudos are nice too
VasTg
Memorable Member
6 years agoAre you trying to create a new column in User_Profile table or is it gonna be a measure?
What is the relationship type between the tables?
How about sharing sample dataset?
- VasTg6 years ago
Memorable Member
I believe you are trying to create a column.
This should work.
2ND Last Invoice Amount =
VAR LAST_DATE =
LASTDATE ( Invoice[Invoice Date] )
VAR PREVIOUS_DATE =
CALCULATE (
MAX ( Invoice[Invoice Date] ),
FILTER ( ALL ( Invoice[Invoice Date] ), Invoice[Invoice Date] < LAST_DATE )
)
RETURN
CALCULATE (
SUM ( Invoice[Invoice Amt] ),
Invoice[Invoice Date] = PREVIOUS_DATE
)If it helps mark it as a solution.
Kudos are nice too
- shanipowerbi6 years ago
Helper III
- shanipowerbi6 years ago
Helper III
Yes trying to get new column, about relationship i have created relationship b/w User IDs