Forum Discussion

Zalexatwork's avatar
Zalexatwork
Frequent Visitor
5 years ago
Solved

Sliception, slicing a slicer

Hello all, It is mostly all in the title. I have a report that is destined to show data over any 14 days (chosen by the user), and on some graphs only I would like to show the data of the last 7 ...
  • mahoneypat's avatar
    5 years ago

    Here is one way to do it.

     

    1.  Make a disconnected 2nd Date table with something like

     

    DisDate = DISTINCT('Date'[Date])
     
    2.  Use that new Date column in your slicer
     
    3. Make a measure to be used as a visual-level filter for all your visuals (measures can't be used as a page filter) to limit the results to only the 14 prior to the selected date
     
    Last14 = var seldisdate = SELECTEDVALUE(DisDate[Date])
    var thisdate = MIN('Date'[Date])
    return IF(thisdate<=seldisdate && thisdate>seldisdate-14, 1)
     
    4. Where you want to show only the last 7 in a visual, use a measure like this
     
    Sales Last 7 Only = var seldisdate = SELECTEDVALUE(DisDate[Date])
    return CALCULATE([Total Sales], KEEPFILTERS('Date'[Date]<=seldisdate && 'Date'[Date]>seldisdate-6))
     

     

    Pat