Forum Discussion

asjones's avatar
asjones
Icon for Helper V rankHelper V
8 years ago
Solved

DAX COUNT IF Based on Date from Another Table

I am trying to create a Measure that counts projects based  on a date. If I do the count and compart the dates in the table to a hard coded date in DAX things work  fine. However if  I try and use a ...
  • v-xjiin-msft's avatar
    8 years ago

    Hi asjones,

     

    Since you have created a many to one relationship between Main_Proj_Master[Project Completed Date]  to a table called Date_Info[Date_From]. And you are using RELATED() function in your expression, you should know that RELATED() function returns a single value that is related to the current row

     

    Which means that you are always doing something like: Main_Proj_Master[Project Completed Date] >= Main_Proj_Master[Project Completed Date]. That's why it returns the complete total.

     

    Then to achieve your requirement, first the condition should be a single specific date like date(2017,07,01) which depends on your logic. Then I think there's no need to create a relationship between the two table. You can try something like below, compare with the MAX date in table Date_Info:

     

    Count Proj 3 =
    COUNTROWS (
        FILTER (
            Main_Proj_Master,
            Main_Proj_Master[Project Completed Date] >= MAX ( Date_Info[Date_From] )
        )
    )

    Thanks,
    Xi Jin.