Forum Discussion
sdukes
Helper I
5 years agocalculate the percent difference between two paychecks
Hi guys! got a question I don't see an answer for...
I am trying to figure out how to calculate the percent difference between two paychecks.
currently I have:
Percent Paycheck over Paycheck =
VAR __PREV_ =
CALCULATE(
SUM('Payroll Dollars'[Dollars]),
DATEADD('DateDAX'[Date].[Date], -14, DAY)
)
RETURN
DIVIDE(SUM('Payroll Dollars'[Dollars]) - __PREV, __PREV)
This works if the difference between two paychecks is 14 days. but it isn't always.
My question is how can I use the table with the dates in it to define that 14 day range instead of the fixed value?
for context = my table may look like this:
| 1/7/2021 | $10 |
| 1/21/2021 | $12 |
| 2/8/2021 | $9 |
| 2/22/2021 | $14 |
(in theory, it's every 14 days - but in reality some of the paychecks are bi-monthly meaning the expected pay date is a weekend, and actual pay is the following day, i.e. a 15 day gap)
I'm looking to reference the dollar value at previous date value (as date appears in the column)
let me know if some further clarification is helpful.
thanks!
is this what you want?
Column = var last=maxx(FILTER('Table','Table'[DATE]<EARLIER('Table'[DATE])),'Table'[DATE]) return maxx(FILTER('Table','Table'[DATE]=last),'Table'[VALUE])
9 Replies
- ryan_mayu
Super User
is this what you want?
Column = var last=maxx(FILTER('Table','Table'[DATE]<EARLIER('Table'[DATE])),'Table'[DATE]) return maxx(FILTER('Table','Table'[DATE]=last),'Table'[VALUE])- sdukes
Helper I
Thank you Ryan! that's super helpful.
Not sure I fully understand it but will keep at it..
Is there any way to make this result be filtered by wither filters or slicers? currently it's a fixed value, but I want it to change on a 'per category' basis