Forum Discussion

Fred905's avatar
Fred905
Regular Visitor
2 years ago

Difference between Current and Previous slicer selected value

Hi, i need help calculating percentage change in cancel rate between current slicer selected value and previous selected value.

 

For example, if the slicer selects 80 and the cancel rate is 43%, when i move the slicer to 100 cancel rate increases to 49%.

I want to be able to calculate the percentage change compared to the previous slicer position.

My DAX logic so far limits calculation to the previous value less than 5 of the current value. 

PreviousCancelRate =
VAR CurrentLeadTime = SELECTEDVALUE('LeadTimeAdjustment'[LeadTimeAdjustment])
VAR PreviousLeadTime = CurrentLeadTime -5
RETURN
    CALCULATE(
        [CR],
        'LeadTimeAdjustment'[LeadTimeAdjustment] = PreviousLeadTime
    )
 
PercentageChange =
VAR CurrentCancelRate = [CR]
VAR PrevCancelRate = [PreviousCancelRate]
RETURN
    IF(
        ISBLANK(PrevCancelRate),
        BLANK(),
        DIVIDE(CurrentCancelRate - PrevCancelRate, PrevCancelRate, 0)
    )

 

1 Reply