Forum Discussion

rbbi's avatar
rbbi
Icon for Advocate II rankAdvocate II
8 years ago
Solved

Sum with DatesInPeriod not working?

Hi, I'm trying some simple DAX but getting a strange result .. trying to sum the last month's data from each date. Also summing the next month's data but this is working OK.   Here is the data......
  • v-piga-msft's avatar
    8 years ago

    Hi  rbbi,

     

    If you want to use DATESINPERIOD function, you'd better create a calendar table.

     

    Such as := CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]),DATESINPERIOD(DateTime[DateKey],DATE(2007,08,24),-21,day))

     

    In the case of not creating a calendar, use filter to determine the specific time range is better.

     

    In addition, I'm a little confused about your logic, if it is convenient could you share your expected output, so that we can help further investigate on it? 

     

    Best Regards,

    Cherry