Forum Discussion
Divide previous row by next row
Hi amitchandak : This is close: But what I want to actually achieve is:
Actual values to find
For our formula for 02-01-2020 we get the divide % for 01-02-2020. Any suggestions on how to achieve the above?
Regards,
PrathSable
Try this calculated column
Percentage =
var nextDate=MAXX(FILTER(ALL('Table'),'Table'[Keyword]=EARLIER('Table'[Keyword])&&'Table'[Date]<EARLIER('Table'[Date])),'Table'[Date])
var nextDateValue= SUMX(FILTER(ALL('Table'),'Table'[Date]=nextDate&&'Table'[Keyword]=EARLIER('Table'[Keyword])),'Table'[Count])
return DIVIDE(nextDateValue,[Count]*'Table'[Actual],BLANK())
Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 🙂
- PrathSable6 years ago
Advocate II
I think I confused you, I do not want the percentage.
I just want to divide earlier record with latest one & then that would need to be multiplied with a corresponding value.
Want to achieve this??
Suggestions?
Regards,
PrathSable
- Anonymous6 years agoNot applicable
Hi PrathSable ,
Incase you want to use Calculated Columns.
Previous Date =CALCULATE (MAX ( 'Table'[Date] ), FILTER(ALLEXCEPT ( 'Table','Table'[Keyword] ),'Table'[Date] < EARLIER( ( 'Table'[Date] ))))Previous Value =CALCULATE (MAX('Table'[Count]) , FILTER(ALLEXCEPT ( 'Table', 'Table'[Keyword] ),'Table'[Date] = EARLIER('Table'[Previous Date])))Divide Val = DIVIDE ('Table'[Previous Value],'Table'[Count])Final Val = 'Table'[Divide Val] * 'Table'[Actual]Regards,
Harsh NathaniDid I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)
- nandukrishnavs6 years ago
Community Champion
Okay Got it.
Val = VAR nextDate = MAXX ( FILTER ( ALL ( 'Table' ), 'Table'[Keyword] = EARLIER ( 'Table'[Keyword] ) && 'Table'[Date] < EARLIER ( 'Table'[Date] ) ), 'Table'[Date] ) VAR nextDateValue = SUMX ( FILTER ( ALL ( 'Table' ), 'Table'[Date] = nextDate && 'Table'[Keyword] = EARLIER ( 'Table'[Keyword] ) ), 'Table'[Count] ) RETURN DIVIDE ( nextDateValue, [Count], BLANK () ) * 'Table'[Actual]
Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 🙂- AlB6 years ago
Community Champion
Just change the order in the DIVIDE () then. You will have to multiply the result by the "actual" column if that is what you need
Calc Column = VAR previousDate_ = CALCULATE ( MAX ( Table1[Date] ), ALLEXCEPT ( Table1, Table1[Keyword] ), Table1[Date] < EARLIER ( Table1[Date] ) ) VAR previousValue_ = CALCULATE ( DISTINCT ( Table1[Count] ), ALLEXCEPT ( Table1, Table1[Keyword] ), Table1[Date] = previousDate_ ) VAR currentValue_ = Table1[Count] RETURN DIVIDE ( previousValue_, currentValue_ )Please mark the question solved when done and consider giving kudos if posts are helpful.
Contact me privately for support with any larger-scale BI needs
Cheers