Forum Discussion

js2246's avatar
js2246
Frequent Visitor
8 years ago

Dynamic Date

I have a case where I have mulitple dates that define unique variables and I want to be able to customize a date range where people can get totals based on the date range selected.

 

So for instance I might have Dates that look like this:

Date1Date2Date3Date4Date5Date6
24-Dec-1631-Jan-1731-Jan-17...
8-Feb-178-Feb-178-Feb-178-Feb-1715-Feb-1713-Feb-17
15-Apr-1713-Apr-1713-Apr-1713-Apr-1713-Apr-1713-Apr-17
8-Feb-1712-Feb-178-Feb-1712-Feb-178-Feb-179-Feb-17
5-Apr-175-Apr-175-Apr-1710-Apr-175-Apr-175-Apr-17
21-Apr-1721-Apr-1723-Apr-17.21-Apr-1729-May-17
25-Mar-1720-Mar-1725-Mar-1703-Apr-1718-Feb-1722-Mar-17
31-Jan-1728-Jan-1731-Jan-1731-Jan-1731-Jan-1731-Jan-17
8-Apr-179-Apr-178-Apr-1710-Apr-178-Apr-1715-Apr-17
26-Jan-1731-Jan-1731-Jan-1702-Mar-1731-Apr-1703-Feb-17

 

So I might have the variables:

var1=sum(if (Date1< 31-Jan-17 , 1, 0))

var2=sum(if (Date2< 31-Jan-17 , 1, 0))

var3=sum(if (Date3< 31-Jan-17 , 1, 0))

etc

 

but I want to be able to change the 31-Jan-17 dynamically based on a date selected how would be the best way to do this?

9 Replies

  • you need a date dimension table in your model, from that table use date as a slicer and in your formula replace "31-Jan-2017" with MAX(DateTable[Date])