Forum Discussion

SUMESHKUMAR22's avatar
SUMESHKUMAR22
Icon for Helper IV rankHelper IV
4 years ago
Solved

Calculation the previous value for % change based on date slicer selection

Hi Team, In a page , I’m having a date range between slicer and showing card e.g. total sales which is simple sum aggregation. scenario needed : I want to create a %change card with indicator 🔺(g...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi SUMESHKUMAR22 ,

     

    I have built a data sample

     

    Please try the following formula to create a measure:

    % change formula = 
    var _curr=CALCULATE(SUM('Table'[Values]),DATESBETWEEN('Table'[Date],MIN('Table'[Date]),MAX('Table'[Date])))
    var _diff=DATEDIFF(MIN('Table'[Date]),MAX('Table'[Date]),DAY)
    var _pre=CALCULATE(SUM('Table'[Values]),  DATESBETWEEN('Table'[Date],MIN('Table'[Date])-_diff,MIN('Table'[Date])))
    return  (_curr - _pre)/_pre

    Then format the measure:

     

    Output:

     

    Best Regards,
    Eyelyn Qin
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Ashish_Mathur's avatar
    Ashish_Mathur
    4 years ago

    Hi,

    Share some data to work with.

  • Ashish_Mathur's avatar
    Ashish_Mathur
    4 years ago

    Hi,

    You may download my PBI file from here.

    Hope this helps.