Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Ramees_123
Helper IV
Helper IV

DAX to find the active companies who credits salary for all the last three months.

Please find the below image. I have 3 tables - Company, Payroll and Date.

 

Company and Payroll has the relationship with Company ID.

Payroll and Date table has the relationship with Salary Date.

 

Ramees_123_0-1626175145537.png

 

I need to know the distinct count of company who credit salary for all the last three months. Payroll table has the salary data until last month June 30, 2021. All the salary dates present are month end dates only.

 

Example :-

Company 1 credits the salary for Apr, May and June. Then it should be taken in count.

Company 2 credits the salary for Apr and June only. For May salary is not credited. Then it should not be taken in count.

 

Please help.

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Ramees_123 , Prefer to have new column and then use the measure below

new column
Month date = eomonth([salary Date], 0)

measure =
countx(filter(Summarize(Table[Company ID],"_1", calculate(distinctcount(Table[month Date]), filter(Table, Table[date]>= eomonth(today(),-3) && Table[date]<= eomonth(today(),-1) ))), [_1] =3),[Company ID])

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Ramees_123 , Prefer to have new column and then use the measure below

new column
Month date = eomonth([salary Date], 0)

measure =
countx(filter(Summarize(Table[Company ID],"_1", calculate(distinctcount(Table[month Date]), filter(Table, Table[date]>= eomonth(today(),-3) && Table[date]<= eomonth(today(),-1) ))), [_1] =3),[Company ID])

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.