Forum Discussion
yasbui
8 years agoFrequent Visitor
How to calculate difference between two row values
Hi I would like to calculate the difference of lost sales between rows but only with stores with the same number only (there is a grouping by date), I'm trying to use a calculated column but I'm ...
- 8 years ago
Hi yasbui
If you have a date column ..you can try using this Calculated Column
Column = VAR First_Date = CALCULATE ( MIN ( Table1[Date] ), ALLEXCEPT ( Table1, Table1[store] ) ) VAR FirstValue = CALCULATE ( SUM ( Table1[lostsales_collected] ), ALLEXCEPT ( Table1, Table1[store] ), Table1[Date] = First_Date ) VAR Second_Date = CALCULATE ( MAX ( Table1[Date] ), ALLEXCEPT ( Table1, Table1[store] ) ) VAR SecondValue = CALCULATE ( SUM ( Table1[lostsales_collected] ), ALLEXCEPT ( Table1, Table1[store] ), Table1[Date] = Second_Date ) RETURN FirstValue - SecondValue
Zubair_Muhammad
8 years agoCommunity Champion
Hi yasbui
If you have a date column ..you can try using this Calculated Column
Column =
VAR First_Date =
CALCULATE ( MIN ( Table1[Date] ), ALLEXCEPT ( Table1, Table1[store] ) )
VAR FirstValue =
CALCULATE (
SUM ( Table1[lostsales_collected] ),
ALLEXCEPT ( Table1, Table1[store] ),
Table1[Date] = First_Date
)
VAR Second_Date =
CALCULATE ( MAX ( Table1[Date] ), ALLEXCEPT ( Table1, Table1[store] ) )
VAR SecondValue =
CALCULATE (
SUM ( Table1[lostsales_collected] ),
ALLEXCEPT ( Table1, Table1[store] ),
Table1[Date] = Second_Date
)
RETURN
FirstValue - SecondValueyasbui
8 years agoFrequent Visitor
Thank you so much! Exactly what I was looking for! :smileyvery-happy: