Forum Discussion
cccarv82
4 years agoFrequent Visitor
How can i subtract a value by date ? [Solved]
I have a table that looks like this: what i need to do to add a column that subtract a certain amount (this certain amount will be a measure) considering the date ? So i have something ...
- 4 years ago
Hi cccarv82
Here is the sample file with the solution https://we.tl/t-eHYz5Ypz3FI hope this is what you're looking for
Actual Value = VAR Current_Value = Table_1[value] VAR Current_Date = Table_1[date_day_by_day] VAR CurrentItem_Table = CALCULATETABLE ( Table_1, ALLEXCEPT ( Table_1, Table_1[Name] ) ) VAR First_Date = MINX ( CurrentItem_Table, Table_1[date_day_by_day] ) VAR Last_Date = MAXX ( CurrentItem_Table, Table_1[date_day_by_day] ) VAR NumberOfDays = DATEDIFF ( First_Date, Current_Date, DAY ) VAR TotalNumberOfDays = DATEDIFF ( First_Date, Last_Date, DAY ) VAR DailyValue = DIVIDE ( Current_Value, TotalNumberOfDays ) RETURN Current_Value - DailyValue * NumberOfDays
tamerj1
Community Champion
4 years agoHi cccarv82
Here is the sample file with the solution https://we.tl/t-eHYz5Ypz3F
I hope this is what you're looking for
Actual Value =
VAR Current_Value = Table_1[value]
VAR Current_Date = Table_1[date_day_by_day]
VAR CurrentItem_Table = CALCULATETABLE ( Table_1, ALLEXCEPT ( Table_1, Table_1[Name] ) )
VAR First_Date = MINX ( CurrentItem_Table, Table_1[date_day_by_day] )
VAR Last_Date = MAXX ( CurrentItem_Table, Table_1[date_day_by_day] )
VAR NumberOfDays = DATEDIFF ( First_Date, Current_Date, DAY )
VAR TotalNumberOfDays = DATEDIFF ( First_Date, Last_Date, DAY )
VAR DailyValue = DIVIDE ( Current_Value, TotalNumberOfDays )
RETURN
Current_Value - DailyValue * NumberOfDays