Forum Discussion
cong_nguyen_acc
6 years agoFrequent Visitor
Calculate variance from previous date
Hi, I have a problem to solve like this; There's a data table contains sales revenue of items by each date. The goal is to create a column that calculates the variance value between the date wit...
- 6 years ago
Try this
VAR = VAR __date = 'Table'[Invoice_Date] VAR __filterTable = ALLEXCEPT( 'Table', 'Table'[SKU_ID] ) VAR __previousDate = CALCULATE( MAX( 'Table'[Invoice_Date] ), __filterTable, 'Table'[Invoice_Date] < __date ) VAR __previousAmt = CALCULATE( SUM('Table'[Amount] ), __filterTable, 'Table'[Invoice_Date] = __previousDate ) RETURN IF( NOT ISBLANK( __previousAmt ), 'Table'[Amount] - __previousAmt )Best Regards,
Mariusz
If this post helps, then please consider Accepting it as the solution.
Please feel free to connect with me.
LinkedIn
Mariusz
6 years agoCommunity Champion
Try this
VAR =
VAR __date = 'Table'[Invoice_Date]
VAR __filterTable = ALLEXCEPT( 'Table', 'Table'[SKU_ID] )
VAR __previousDate =
CALCULATE(
MAX( 'Table'[Invoice_Date] ),
__filterTable,
'Table'[Invoice_Date] < __date
)
VAR __previousAmt =
CALCULATE(
SUM('Table'[Amount] ),
__filterTable,
'Table'[Invoice_Date] = __previousDate
)
RETURN IF( NOT ISBLANK( __previousAmt ), 'Table'[Amount] - __previousAmt )
Best Regards,
Mariusz
If this post helps, then please consider Accepting it as the solution.
Please feel free to connect with me.
LinkedIn
Mariusz
If this post helps, then please consider Accepting it as the solution.
Please feel free to connect with me.