Forum Discussion

Talal141218's avatar
Talal141218
Icon for Helper III rankHelper III
3 years ago
Solved

Filter next two years based on Today

Hi Experts,  I want to filter quantity in the sales orders in the next 2 years. I traid to create a mesure, but it's not work as below :  CALCULATE([CM_SalesLine_SalesOrderLine_OrderQuantity], Fac...
  • ValtteriN's avatar
    3 years ago

    Hi,

    Here is one way to do this:

    example data:

    Here we will show values 1, 2 and 3 since 4 and 5 are outside the 2 year period wanted.

    In addition to the original table we will need a calendar table:

     



    Dax:

    Measure 2 =
    var _sdate = TODAY()
    var _edate = MAXX(CALCULATETABLE(DATEADD('Calendar'[Date],2,YEAR),FILTER('Calendar','Calendar'[Date]=TODAY())),[Date]) return
    CALCULATE(SUM('Table (4)'[Value]),ALL('Calendar'),DATESBETWEEN('Calendar'[Date],_sdate,_edate))

    End result:

     

    I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

    My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/