Forum Discussion
Creating a Dynamic Date Filter
- 7 years ago
You may try the measure below.
Measure = VAR d = MAX ( 'Table'[Date Last Changed] ) RETURN SUMX ( SUMMARIZE ( FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date Last Changed] <= d ), 'Table'[Opportunity ID], "V", SUMX ( TOPN ( 1, 'Table', 'Table'[Date Last Changed], DESC ), 'Table'[Value] ) ), [V] )
Use the same logic that you already have. You can either use a separate date table for your slicer or utilize the ALL function. So, essentially, something like:
Measure =
VAR __maxDate = MAX('Table'[Date])
VAR __table = FILTER(ALL('Table'),[Date] <= __maxDate)
...
After that it should essentially the same logic that you have currently.
Thank you so much Greg_Deckler!
A consultant helped me with the formula to find our current latest value - she made it in a new column with this formula:
Latest Value = IF('Table'[DateChanged]=CALCULATE(MAX('Table'[DateChanged]), FILTER('Table', EARLIER('Table'[Opportunity ID]) = 'Table'[Opportunity ID])),CALCULATE(MAX('Table'[Value]), FILTER('Table','Table'[Opportunity ID]=EARLIER('Table'[Opportunity ID]) && 'Table'[DateChanged] = CALCULATE(MAX('Table'[DateChanged]), FILTER('Table', EARLIER('Table'[Opportunity ID]) = 'Table'[Opportunity ID])))),0)
I tried creating a measure with your suggestion and I believe it would look something like the below but obviously, this isn't correct because it doesn't work... :( Thoughts?
Measure =
VAR __maxDate = MAX('Table'[DateChanged])
VAR __table = FILTER(ALL('Table'),[DateChanged] <= __maxDate)
return
IF('Table'[DateChanged]=CALCULATE(MAX('Table'[DateChanged]), FILTER('Table', EARLIER('Table'[Opportunity ID]) = 'Table'[Opportunity ID])),CALCULATE(MAX('Table'[Value]), FILTER('Table','Table'[Opportunity ID]=EARLIER('Table'[Opportunity ID]) && 'Table'[DateChanged] = CALCULATE(MAX('Table'[DateChanged]), FILTER('Table', EARLIER('Table'[Opportunity ID]) = 'Table'[Opportunity ID])))),0)Thank you so much!!
- v-chuncz-msft7 years ago
Community Support
You may try the measure below.
Measure = VAR d = MAX ( 'Table'[Date Last Changed] ) RETURN SUMX ( SUMMARIZE ( FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date Last Changed] <= d ), 'Table'[Opportunity ID], "V", SUMX ( TOPN ( 1, 'Table', 'Table'[Date Last Changed], DESC ), 'Table'[Value] ) ), [V] )- phay7 years agoRegular Visitor
Thank you v-chuncz-msft ! I can tell this is getting me closer to the result I'm looking for! I'm going to try tinkering with it and I will report back if I get it!