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
IsaacAsher
Helper I
Helper I

DAX Days between two dates in different tables with filter

I have a table I'm trying to summarize:

Master table
ID    Worked
1      1/1/2018

2      3/4/2017

3      5/2/2015

4      6/7/2018
....

 


by using my specialized Calendar table:
Date            PostingDay
1/1/2018    False
1/2/2018    True
1/3/2018     True
1/4/2018    True

.....

 

 
I need to add either a column or measure to the master table which will count the days in the Calendar table between master.worked and today, but only where Calendar.PostingDay = TRUE. 

I have a relationship between the master table and calendar table joining Calendar.Date as a one-to-many with master.Worked. 

Still pretty new to DAX so I've muddled myself under CALCULATE, COUNTX, etc and I'm not sure how to get this info.

 

Any ideas?  Thanks in advance

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

I believe you want something along the lines of:

 

 

Measure = 
VAR __worked = MAX('Master'[Worked])
RETURN
COUNTX(FILTER(ALL('Calendar'),[PostingDay] = TRUE() && [Date]<=TODAY() && [Date]>=__worked),[Date])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

 

Could you share the exact expected layout and result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Greg_Deckler
Super User
Super User

I believe you want something along the lines of:

 

 

Measure = 
VAR __worked = MAX('Master'[Worked])
RETURN
COUNTX(FILTER(ALL('Calendar'),[PostingDay] = TRUE() && [Date]<=TODAY() && [Date]>=__worked),[Date])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.

Top Solution Authors