Forum Discussion
Select one date to filter data between two dates
Hi team, wondering if I can please get some help with this.
I have an asset table with DateFrom and DateTo. A new row is created in the database on the following date when there has been a change to the asset. See example below. I also have a separate Date table.
I want to be able to select one particular date on a slicer, and see what the attributes of my asset were at that date only.
This date may fall on the start or end dates, or within those dates.
For example, if I selected 1/6/2019, my asset amount would be 60.
Or if I selected 1/12/2019 my asset amount would be 150.
Seems pretty straight forward but I'm unsure. Help much appreciated.
Hi Anonymous ,
You could try the following measure:
Measure = VAR a = SELECTEDVALUE ( 'Date'[Date] ) RETURN CALCULATE ( CALCULATE ( MAX ( 'Table'[Amount] ), ALLEXCEPT ( 'Table', 'Table'[ID] ) ), FILTER ( 'Table', 'Table'[DateFrom] <= a && 'Table'[DateTo] >= a ) )
6 Replies
- amitchandakSuper User
Anonymous , Try with disconnected date table. That Dat table should be used in slicer
measure =
var _min = minx(allselected(Date),Date[Date])
return calculate(sum(Table[Amount]), filter(Allselected(Table),Table[DateFrom]<=_min && Table[DateTo]>=_min))In the case, the date table is connected use crossfilter to remove join
example in this blog. Also if this blog's current employee calc can help you.
- FowmySuper User
Anonymous
Try this measure, and add it in the visual filter, hope you haven't connected the date table to the asset table, it should disconnected dates tablem_DateSelected = VAR _DATE = SELECTEDVALUE(Dates[Date]) RETURN IF( _DATE >= MAX(ASSETS[DATEFROM]) && _DATE <= MAX(ASSETS[DATETO]), 1, 0 )If you are satisfied with my answer, please mark it as a solution so others can easily find it.
Don't forget to give KUDOS ? to replies that help answer your questions
Subscribe to ExcelFort: Learn Power BI, Power Query and Excel- AnonymousNot applicable
Thanks; this does work but as soon as I summarize the data the totals seem to blow out.
- FowmySuper User
Anonymous
This is supposed to work on the data layout you presented.If you are satisfied with my answer, please mark it as a solution so others can easily find it.
Don't forget to give KUDOS ? to replies that help answer your questions
Subscribe to ExcelFort: Learn Power BI, Power Query and Excelwork on the data layout you showed.
- v-eachen-msftCommunity Support
Hi Anonymous ,
You could try the following measure:
Measure = VAR a = SELECTEDVALUE ( 'Date'[Date] ) RETURN CALCULATE ( CALCULATE ( MAX ( 'Table'[Amount] ), ALLEXCEPT ( 'Table', 'Table'[ID] ) ), FILTER ( 'Table', 'Table'[DateFrom] <= a && 'Table'[DateTo] >= a ) )