Forum Discussion

kevin_peña's avatar
kevin_peña
Regular Visitor
3 years ago

How to get data range from slicer

Good day 

I need to calculate the days between the data range of a slicer. I've been using the ALLSELECTED function but i noticed that the value it gets me is from the table that is linked to the slicer, not the slicer itself. So when i use another slicer that's linked to the same table, it gets me two values 

For example, in this picture, the date slicer goes from 10/1/2022 to 12/15/2022 and the last date in the table is 12/15/2022 (as you can see in the card). But if i change the slicer in left (The Status), it automatically changes the date according to the last date in the table (as you can see in the card, image below), but is not the same date of the max range of the slicer. 

As i said before, what i need is the min and max range of the date slicer (in this case 10/1/2022 - 12/15/2022) regardless of the data on the table

 

Kind regards  

 

6 Replies

    • kevin_peña's avatar
      kevin_peña
      Regular Visitor

      The thing is that i need the values for a measure, and it has to be the same values in the date slicer regardless of the filter in the status slicer. If i select the dates from 10/1/2022 to 12/15/2022, it should count 14 days whether the status slicer is in "ABORTED" or not

  • samdthompson's avatar
    samdthompson
    Memorable Member

    Hello, make this measure. It will just pickup the min and max date from the slicer:

     

    DayDiff =
    var _min=FIRSTDATE(Query1[Raised_date])
    var _max=LASTDATE(Query1[Raised_date])
    return
    DATEDIFF(_min,_max,DAY)
     
    Cheers
    • kevin_peña's avatar
      kevin_peña
      Regular Visitor

      This one looks good but it gives me the whole number of days since the table was created, the table starts on 1/31/2016 and ends today 12/19/2022 so the result is 2556 days, that means is ignoring the slicer filter

       

  • samdthompson's avatar
    samdthompson
    Memorable Member

    Hello, make sure your slicer you have there is filtering the card and that the measure is using the same table as used in the slicer

     

     

    • kevin_peña's avatar
      kevin_peña
      Regular Visitor

      Thanks for answering in short notice. I've checked in the interactions and the card is being filtered by the date slicer but still is not showing the values it should. The only thing i changed of your formula is that i'm using the .[Date] cause it was showing an error