0

I am using the slider interface to select date interval (date1 to date2), as illustrated below. I need that the default value for date1 is "now()- 20 days"... It is possible to do this? Perhaps using DAX, but how to do this?

enter image description here


NOTES

  • a global (page) filter with the logic "last 20 days" is a workaround but it is not a solution because reduce the slider domain. I need to use all the dates in a big range... The set default date1 logic is only "to be friend with the user", offering a good start view of the dashboard, but not eliminating the big range.

  • (edited after @StelioK's answer). I need that the online dashboard starts with this "pre-selected date"... If I put with the mouse the slider in the position that I need (middle), save and publish the dashboard, ok, every user will open it as "default state" (open dashboard with slider in the middle). But I can't do it every day and all my life, I need to automatize the process.

  • Analogy: the selected attribute of HTML interface offers a way to change default start-option.

Community
  • 1
  • 1
Peter Krauss
  • 13,174
  • 24
  • 167
  • 304
  • 1
    I just tried one way, may be it could be of your help. Create a "RowNumber" calculated column, it can be index if you table is simple or you can calculate manually. Now create one more field "StartDateMinusTwenty" and for your first row you can have something like now()-20 and the rest rows will be left untouched i.e they will have value from your date. In this way you will not loose your date1 but 1st value will be today-20 days. Now use this new column in your slicer. I am not sure if this fits your req but a idea. – AnkUser Aug 27 '19 at 15:07
  • Thanks @AnkUser, make sense.. But the only box to add a second variable is about "detail" and is for "categories"... There is **no customizable field for `date1`** where I can plug this new external variable or column. – Peter Krauss Aug 27 '19 at 15:31
  • do you mean you cannot add calculated columns? – AnkUser Aug 28 '19 at 09:55
  • 1
    Hi @AnkUser, yes, is the usual workaround for Power BI, but in this case it not the solution if there are no correct place to add this column. The correct place is a "`selected` analogous", that only sets start state of the slider when you open the dashboard... See the last item of my Notes, there are a **`selected` analogous** to use with DAX? – Peter Krauss Aug 28 '19 at 10:26

1 Answers1

0

Sure you can! Just create a flag, you can add this as a calculated column to your date table using the following DAX.

[Is In Interval] :=
SWITCH ( TRUE (), 'Date'[Date] >= TODAY () - 20, 1, 0 )

Then, add this field under the 'Visual Level Filter' property within the visual and set it equal to 1. That should do the trick!

Hope it helps!

StelioK
  • 1,771
  • 1
  • 11
  • 21
  • Hi, perhaps I not see on the complex menus/interface of Power BI... But not seems a solution: I need to preserve the slider as it, with no filter. The problem is the access to the "pre-selected value" of the slider (like a user putting with mouse the slider in the midle and another user see it as starting state). – Peter Krauss Aug 27 '19 at 17:57
  • @PeterKrauss Not sure if I am following you but you cannot accomplish what you are trying to do without a filter on the slicer itself. – StelioK Aug 27 '19 at 18:14