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

Filter date range based on another date range

Hello,

 

I have a table that have date start and date end

I have a date filter

I want to filter rows that have have at least one day in the date range

Is there something wrong with the logic, here?

Measure = CALCULATE(DISTINCTCOUNT(work_sessions_processed[user_id]),or(work_sessions_processed[date_end]>=MIN('Calendar'[Date]),work_sessions_processed[date_start]<=MAX('Calendar'[Date])))
 
Thanks
1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Mumin192 

please try

Measur =
CALCULATE (
    DISTINCTCOUNT ( work_sessions_processed[user_id] ),
    FILTER (
        work_sessions_processed,
        VAR StartDate = work_sessions_processed[date_start]
        VAR EndDate = work_sessions_processed[date_end]
        VAR Dates1 =
            CALENDAR ( StartDate, EndDate )
        VAR Dates2 =
            VALUES ( 'Calendar'[Date] )
        RETURN
            NOT ISEMPTY ( INTERSECT ( Dates1, Dates2 ) )
    )
)

View solution in original post

1 REPLY 1
tamerj1
Super User
Super User

Hi @Mumin192 

please try

Measur =
CALCULATE (
    DISTINCTCOUNT ( work_sessions_processed[user_id] ),
    FILTER (
        work_sessions_processed,
        VAR StartDate = work_sessions_processed[date_start]
        VAR EndDate = work_sessions_processed[date_end]
        VAR Dates1 =
            CALENDAR ( StartDate, EndDate )
        VAR Dates2 =
            VALUES ( 'Calendar'[Date] )
        RETURN
            NOT ISEMPTY ( INTERSECT ( Dates1, Dates2 ) )
    )
)

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