Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

How to Link Relative Date Slicer with Previous Period Measure

Hiya,    I am making some KPI cards, and am wishing to link the target values to the relative date slicer. (weeks, months, etc)   For example, when I choose "Last 2 months", I would like to get a...
  • amitchandak's avatar
    3 years ago

    Anonymous , Try measure like

     

    Last month  =
    var _max1 = if(isfiltered('Date'),Min( 'Date'[Date]) , today())
    var _max = eomonth(_max1,-1)
    var _min = eomonth(_max1,-2)+1
    return
    CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

     

     

    Last week =
    var _max1 = if(isfiltered('Date'),Min( 'Date'[Date]) , today()) -7
    var _max = _max1 - weekday(_max,2)+7
    var _min = _max1 - weekday(_max,2)+1
    return
    CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))