Forum Discussion
KW123
Helper V
4 years agoSubtracting two rows
Hi, I am hoping someone can help. I have a column with sales values and I need to create a DAX where I minus A from B to get C but then take C and minus it from B to get D. Then D-B=E etc for t...
- 4 years ago
Hi KW123
Sorry it was too late yesterday I couldn't reply to you. Here is a sample file with the solution jnowing that you will retun back to me with more information that you've been hiding as usual 😉https://www.dropbox.com/t/lzKxh0DxLA056sy7Result = VAR A = 1000 VAR B = 10 VAR CurrentIndex = SELECTEDVALUE ( Data[INDEX] ) VAR MaxIndex = CALCULATE ( MAX ( Data[INDEX] ), ALLEXCEPT ( Data, Data[Day].[Month] ) ) RETURN IF ( CurrentIndex <> BLANK ( ), A - ( MaxIndex - CurrentIndex ) * B ) - 4 years ago
What does YTD total need to be = VAR A = [Accounting goal calc-c] VAR B = [Daily Goal] VAR CurrentIndex = SELECTEDVALUE ( Dates[FD2] ) VAR MaxIndex = CALCULATE ( MIN ( Dates[FD2] ), ALLEXCEPT ( Dates, Dates[Date] ) ) RETURN IF ( DAY ( SELECTEDVALUE ( Dates[Day] ) ) = 1 && MONTH ( SELECTEDVALUE ( Dates[Day] ) ) = 1, 0, IF ( CurrentIndex <> BLANK (), A + ( MaxIndex - CurrentIndex ) * B ) )
KW123
Helper V
4 years agotamerj1 Yes this could work, I just don't know how to turn that into a measure or a calculated column
tamerj1
Community Champion
4 years agoKW123
I think this is the time were you have to disclose some sample data so I can complete my answer.
- KW1234 years ago
Helper V
tamerj1 Does this help?
Day INDEX What I am trying to calculate 1 Saturday 1 $810 2 Sunday 3 Monday (HOLIDAY) 1 $810 4 Tuesday 2 $820 5 Wednesday 3 $830 6 Thursday 4 $840 7 Friday 5 $850 8 Saturday 5 $850 9 Sunday 10 Monday 6 $860 11 Tuesday 7 $870 12 Wednesday 8 $880 13 Thursday 9 $890 14 Friday 10 $900 15 Saturday 10 $900 16 Sunday 17 Monday HOLIDAY 10 $900 18 Tuesday 11 $910 18 Wednesday 12 $920 20 Thursday 13 $930 21 Friday 14 $940 22 Saturday 14 $940 23 Sunday 24 Monday 15 $950 25 Tuesday 16 $960 26 Wednesday 17 $970 27 Thursday 18 $980 28 Friday 19 $990 29 Saturday 19 $990 30 Sunday 31 Monday 20 $1000 (I only know this number, I need to work in reverse from here)
The first value I am subtracting from is the "$1000" and I will move up the month backwards. Assume the "B" value is $10 so we will need to subtract the $10 from every new row. The index column is based on filters on days of the week/holidays