Forum Discussion

ReadTheIron's avatar
ReadTheIron
Helper III
5 years ago
Solved

Count Occurrences Since Date

I have two tables, one which records Assets and Repair Date, the other Assets and Failure Date. They're joined by a one-to-many relationship on Assets.

I want to add a column to Table1 that counts the number of failures that occur after the repair date, resulting in something like this:

I suspect this is quite simple, but I'm new to DAX and haven't been able to figure it out on my own. Any help appreciated!

 

 

 

 

 

  • ReadTheIron 

    you can create relationship between two tables and create a column

    Column = if(ISBLANK(Table1[Repair Date]),0,COUNTX(FILTER(RELATEDTABLE(Table2),'Table1'[Repair Date]<='Table2'[Failure Date]),'Table2'[Failure Date])+0)

    pls see the attachment below

3 Replies

  • ReadTheIron 

    you can create relationship between two tables and create a column

    Column = if(ISBLANK(Table1[Repair Date]),0,COUNTX(FILTER(RELATEDTABLE(Table2),'Table1'[Repair Date]<='Table2'[Failure Date]),'Table2'[Failure Date])+0)

    pls see the attachment below

    • ReadTheIron's avatar
      ReadTheIron
      Helper III

      Thank you! That works perfectly - and now I know how to do it for next time 😀