Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Multiple DATESBETWEEN filtering

I got two tables with following data. However, ExcludeRange StartDate and EndDate are measures instead of calculated columns for reason it is derived from whatif paramter then can't be calculated col...
  • Anonymous's avatar
    Anonymous
    6 years ago

    amitchandakThanks your reply. Anyway, i can't make a reference to filter ExcludeRange by 'Sales'[person] and 'Sales'[date] as there is no relationship between the two tables. There are 'Person' & 'CalendarDates' tables which have relationship with these two tables. Finally i used Generate to build up a casterian between Sales and ExcludeRange and then do the filtering and the result seems work. As I am not quite familiar with DAX, it may not be simplied and optimized yet. Hope anyone has similar issue will find this help.

    Exclude Sales = sumx('Person',         
    calculate(sum(Sales[Value]), filter(generate(Sales, ExcludeRange),
                Sales[Date]>= ExcludeRange[StartDate] && Forecast[Date]<= calculate(ExcludeRange[EndDate], Allexcept(Sales, Sales[Person])) && Sales[Person] = ExcludeRange[Person]), Sales[Person] = earlier('Person'[Person])
           )
       )