Forum Discussion

Gilly66's avatar
Gilly66
Frequent Visitor
2 years ago
Solved

Dax

I was looking to write a dax expression that would result in me being able to see all expiring contracts in 18 months 
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Gilly66 ,

    I assume you have the following data:

    Please create a new measure for visuals filter:

    Measure = 
    VAR CurrentDate = TODAY()
    VAR FutureDate = EDATE(CurrentDate, 18)
    RETURN
    IF(SELECTEDVALUE('Table'[End Date])>=CurrentDate &&SELECTEDVALUE('Table'[End Date])<=FutureDate,1)

    And apply it to the filter:

    If you want to get the number of expiring contracts, create another new measure:

    Amount = 
    VAR CurrentDate = TODAY()
    VAR FutureDate = EDATE(CurrentDate, 18)
    RETURN
    CALCULATE(
        COUNTROWS('Table'),
        FILTER(
            ALL('Table'),
            'Table'[End Date] >= CurrentDate && 'Table'[End Date] <= FutureDate
        )
    )
    

    And the output:

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group