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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
San_Raz
Frequent Visitor

Marking Dates In Between Two Dates (for Displaying Time Spread in days of an activity)

I have two tables 
Table 1 : WorkSchedule

 ActivityDate Expected Finish Client
 A01/01/2025 04/01/2025 SS
 A01/01/2025 3/01/2025 DD
 C05/01/2025 8/01/2025 SS


And table two is a Date Table.

I have connected the date column in date table to the Date column in WorkSchedule table  using a One to many relationship 
with Workschedule lying in the many side.

San_Raz_0-1736933363719.png



I need to create matrix table with the dates and activities listed down as below. the dates in-between the Date and ExpectedFinish to be counted as 1.

ActityClient01/01/202502/01/202503/01/202504/01/202505/01/202506/01/202507/01/202508/01/202509/01/202510/01/202511/01/202512/01/2025
ASS1111        
ADD111         
CSS    1111    



Also, i have been trying the beow dax but it is only  counting  the start dates with 1
Count_Working = COUNTX
                                           (FILTER(WorkSchedule,
                                                          WorkSchedule[Date] <= MAX(Date[Date]) &&
                                                           WorkSchedule[EXPECTED FINISH] >= MAX(Date[Date])),
                                                           WorkSchedule[Activity])
Let me know if any other info is required

1 ACCEPTED SOLUTION

Sorry for tytping mistake.

I have corrrected it

 

Answer = 
VAR mydate = SELECTEDVALUE('Calendar'[Date])
VAR tempfile = 
FILTER(yourdata, 
mydate >= yourdata[Start date] &&
mydate <= yourdata[Finish date]
)
RETURN
COUNTROWS(tempfile)

 

 

 

 

View solution in original post

7 REPLIES 7
speedramps
Super User
Super User

Try this ....

 

Remove the Calendar relationship.

)Calendar relations should not be used forstart to finish date sceranrios because the rleationshiop will only work on one date and not the dates inbetween)

 

Create measure (using you own table and column names)

 

Answer = 
VAR mydate = SELECTEDVALUE('Calendar'[Date])
VAR tempfile = 
FILTER(yourdata, 
mydate >= yourdata[Start date] &&
mydate <= yourdata[Finish date]
)
RETURN
COUNTROWS(yourdata)

 

 

Add a matric visual to your reports

speedramps_0-1736935392628.png

 

Please click the [accept solution] and thumbs up button.

At the very least click the thumbs up button to show your appreciation.

Thank you. 😀

Hi,
In your A -SS ends on 05th , but in your result it is counted for days after that also.
I also tested your approach, but it is giving Wrong output

San_Raz_1-1736936921595.png

 

 

 

johnt75
Super User
Super User

I think you can use

Date is active =
VAR StartDate =
    SELECTEDVALUE ( WorkScheduleWorkSchedule[Date] )
VAR EndDate =
    SELECTEDVALUE ( WorkSchedule[Expected Finish] )
VAR CurrentDate =
    SELECTEDVALUE ( 'Date'[Date] )
VAR Result =
    IF ( StartDate <= CurrentDate && CurrentDate <= EndDate, 1 )
RETURN
    Result


Its counting for all dates

San_Raz_2-1736935653482.png

 

 

Sorry for tytping mistake.

I have corrrected it

 

Answer = 
VAR mydate = SELECTEDVALUE('Calendar'[Date])
VAR tempfile = 
FILTER(yourdata, 
mydate >= yourdata[Start date] &&
mydate <= yourdata[Finish date]
)
RETURN
COUNTROWS(tempfile)

 

 

 

 

San_Raz_0-1736937560998.png

Perfect, Thanks.
I have a doubt, without relation between the two tables, how is the matrix visual able  determine the relation between the coulmn and Rows.

Thanks in Advance

I hace added some explanatory commnents the DAX measure to help answer your question "how is the matrix visual able  determine the relation between the coulmn and Rows without relation between the two tables."

 

When Power Bi plots a matrix it does the DAX calculation for each cell which will have natural filter context for the rows and columns.

 

Please click [accept solution] and thumbs up buttons. Thank you

 

Answer = 
// get the date for the column context on the visual 
VAR mydate = SELECTEDVALUE('Calendar'[Date])

// create a temp file of yourdate 
// which will naturally be filtered by the row Activity and Customer contect in the visual
// but we add additional date filters
VAR tempfile = 
FILTER(yourdata, 
mydate >= yourdata[Start date] &&
mydate <= yourdata[Finish date]
)
RETURN
// count the rows in the temp file for the visual cell context 
// which has Activity and Customer row context and Date column context
COUNTROWS(tempfile)

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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