Forum Discussion

ClemFandango's avatar
ClemFandango
Advocate II
2 years ago
Solved

Sum column based on if date is between two dates

Hi there,

 

I have the following tables, and i am trying to count the number of rows in 'Table 2' where 'Lost' = 1 and the data in 'Table 1' is the same month. I am trying to do this by adding a custom column to 'table 1' using DAX.

 

Table 1 - Example

MMYYDD = end of month

 

Table 2 Example:-

 

Example of data from Table 2

Expanded_DateLost
01/09/231
02/09/230
03/09/231
01/10/231
15/12/231

 

I am hoping to achieve the following in 'Table 1' by adding a calculated column called 'Lost':-

MMYYDDLost
30/09/232
31/10/231
30/11/230
31/12/231
31/01/240
29/02/240

 

Any ideas or help greatly appreciated!

 

CF

 

 

 

 

  • ClemFandango , a new column in dax in Table 1

     

    countx(filter(Table2, eomonth(Table1[Date], 0)  = eomonth(Table2[date],0) && [Lost] =1), [Lost])

2 Replies