DAX Calculation for Prior Period Date Range

Viewed 342

Period Column is broken up into 2 month increments. I need to compare values vs the previous period and am not sure the DAX Formula. Below is what I have in PBI and then what I am looking to create. After this I need to show the Variance. (period is based of a Date Column)

enter image description here

enter image description here

1 Answers

Because your periods are not unique, we need to generate a unique identifier in order to find the previous period. Create this calculated column:

PERIOD_ID:=RANKX(ALL(Table1),Table1[Year]&Table1[Period],,ASC)

Then we can reference that period ID to pull the previous period values, or none if it is the first period.

PREV_PERIOD_ACHIEVED:=var curPeriod = Table1[PERIOD_ID]

RETURN

IF(curPeriod = 1,0,CALCULATE(MAX(Table1[Achieved]),FILTER(Table1,Table1[PERIOD_ID]=curPeriod-1)))

enter image description here

Related