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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
zohlander
New Member

Count a register if its between the start date and end date

Hi! How are u? I was developing a DAX Measure and I got stucked.

 

I have a Calendar table and a fact table with a start date and a enddate. The calendar has an active relationship with the fact table by the column "start date", "enddate" is inactive.

 

I want to graph a bar chart with week as x axis and count the registers that had not ended yet.

 

For example: A register has a start date equal to 03/01/2024 (DD/MM/YYYY) and a end date equal to 23/01/2024. I have a month filter, if a select January I want to see this:

 

Week 1 : 1 (1/1/2024 - 7/1/2024) The register have been created
Week 2:  1 (8/1/2024 - 15/1/2024) Still open

Week 3:  1 (16/1/2024 - 23/1/2024) Still open

Week 4:    0 The register reached the end date

 

I want to graph this in a bar chart.

 

I would be very glad if you can help me! Thank you so much

 

2 ACCEPTED SOLUTIONS
mh2587
Super User
Super User

Ongoing Registrations = 
VAR SelectedMonth = SELECTEDVALUE('Calendar'[Month])
RETURN
CALCULATE(
    COUNTROWS('FactTable'),
    FILTER(
        'FactTable',
        RELATED('Calendar'[Date]) >= 'FactTable'[Start Date] &&
        (ISBLANK('FactTable'[End Date]) || RELATED('Calendar'[Date]) <= 'FactTable'[End Date])
    ),
    'Calendar'[Month] = SelectedMonth
)
//Try this one

Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



View solution in original post

Anonymous
Not applicable

Hi @zohlander ,

@mh2587 Thanks for your concern about this case!
I build a sample data myself:

vjunyantmsft_0-1712307904893.png
vjunyantmsft_1-1712307912942.png

Please note that delete the relationships between the two tables:

vjunyantmsft_2-1712307975728.png

I use this DAX to create a measure:

Measure = 
var _add=ADDCOLUMNS('fact table',
"counts",
var _date=CALENDAR([start date],[end date])
var _calendardate=VALUES('Calendar table'[Date])
RETURN COUNTROWS(INTERSECT(_date,_calendardate)))
RETURN COUNTROWS(FILTER(_add,[counts]>0))

Then the final output is as below:

vjunyantmsft_3-1712308025804.png

vjunyantmsft_4-1712308032789.png


Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
johnbasha33
Super User
Super User

@zohlander 
you may want to use this
RegistrationCheck =
VAR SelectedMonth = SELECTEDVALUE('CalendarTable'[Month])
RETURN
CALCULATE(
COUNTROWS('FactTable'),
FILTER(
'FactTable',
RELATED('CalendarTable'[Date]) >= 'FactTable'[Start Date] &&
(ISBLANK('FactTable'[End Date]) || RELATED('CalendarTable'[Date]) <= 'FactTable'[End Date])
),
'CalendarTable'[Month] = SelectedMonth
)

Anonymous
Not applicable

Hi @zohlander ,

@mh2587 Thanks for your concern about this case!
I build a sample data myself:

vjunyantmsft_0-1712307904893.png
vjunyantmsft_1-1712307912942.png

Please note that delete the relationships between the two tables:

vjunyantmsft_2-1712307975728.png

I use this DAX to create a measure:

Measure = 
var _add=ADDCOLUMNS('fact table',
"counts",
var _date=CALENDAR([start date],[end date])
var _calendardate=VALUES('Calendar table'[Date])
RETURN COUNTROWS(INTERSECT(_date,_calendardate)))
RETURN COUNTROWS(FILTER(_add,[counts]>0))

Then the final output is as below:

vjunyantmsft_3-1712308025804.png

vjunyantmsft_4-1712308032789.png


Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

mh2587
Super User
Super User

Ongoing Registrations = 
VAR SelectedMonth = SELECTEDVALUE('Calendar'[Month])
RETURN
CALCULATE(
    COUNTROWS('FactTable'),
    FILTER(
        'FactTable',
        RELATED('Calendar'[Date]) >= 'FactTable'[Start Date] &&
        (ISBLANK('FactTable'[End Date]) || RELATED('Calendar'[Date]) <= 'FactTable'[End Date])
    ),
    'Calendar'[Month] = SelectedMonth
)
//Try this one

Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors