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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
PowerPuff36
Regular Visitor

Multiple date filters in measure for table

Hi all,

 

Hoping someone can help as i have been stuck for 3 days now! 

 

I am trying to create a table which shows this weeks data next to the previous weeks data. Using a slicer we want to be able to change the date so the table will update. The issue i have is we need to account for multiple date filters. 

 

So the requirements are - 

 

StartDate needs to be before or equal to date selected

EndDate needs to be after or equal to date selected 

CancelledDate needs to be after or equal to date selected OR blank

UserStatus must equal active

 

I did think i could maybe make userelationship work and tested it with just the StartDate but it doesn't like it 

CALCULATE (COUNTROWS( UserTable ),FILTER (UserTable,UserTable[Department]), UserTable[startdate] <=USERELATIONSHIP(UserTable[startdate],'Calendar'[Date]))


I have tried so many variations through help from articles and looking through the community but no luck! Any help would be greatly appreciated! 

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @PowerPuff36 

 

Assume your UserTable is like below and you have a Calendar table, you don't need to create a relationship between them. 

22012603.jpg

 

Put date column from Calendar table into a slicer for users to pick a date. Then you could create below measures to get the count on the selected date and on the date 7 days ago (previous week). You can use && (AND) and || (OR) to combine multiple filters. 

This Week Count =
VAR __selectedDate = SELECTEDVALUE ( 'Calendar'[Date] )
RETURN
    COUNTX (
        FILTER (
            UserTable,
            UserTable[StartDate] <= __selectedDate
                && UserTable[EndDate] >= __selectedDate
                && (
                    UserTable[CancelledDate] >= __selectedDate
                        || ISBLANK ( UserTable[CancelledDate] )
                )
                && UserTable[UserStatus] = "Active"
        ),
        UserTable[UserId]
    )
Previous Week Count =
VAR __selectedDate = SELECTEDVALUE ( 'Calendar'[Date] ) - 7 
RETURN
    COUNTX (
        FILTER (
            UserTable,
            UserTable[StartDate] <= __selectedDate
                && UserTable[EndDate] >= __selectedDate
                && (
                    UserTable[CancelledDate] >= __selectedDate
                        || ISBLANK ( UserTable[CancelledDate] )
                )
                && UserTable[UserStatus] = "Active"
        ),
        UserTable[UserId]
    )

22012604.jpg

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @PowerPuff36 

 

Assume your UserTable is like below and you have a Calendar table, you don't need to create a relationship between them. 

22012603.jpg

 

Put date column from Calendar table into a slicer for users to pick a date. Then you could create below measures to get the count on the selected date and on the date 7 days ago (previous week). You can use && (AND) and || (OR) to combine multiple filters. 

This Week Count =
VAR __selectedDate = SELECTEDVALUE ( 'Calendar'[Date] )
RETURN
    COUNTX (
        FILTER (
            UserTable,
            UserTable[StartDate] <= __selectedDate
                && UserTable[EndDate] >= __selectedDate
                && (
                    UserTable[CancelledDate] >= __selectedDate
                        || ISBLANK ( UserTable[CancelledDate] )
                )
                && UserTable[UserStatus] = "Active"
        ),
        UserTable[UserId]
    )
Previous Week Count =
VAR __selectedDate = SELECTEDVALUE ( 'Calendar'[Date] ) - 7 
RETURN
    COUNTX (
        FILTER (
            UserTable,
            UserTable[StartDate] <= __selectedDate
                && UserTable[EndDate] >= __selectedDate
                && (
                    UserTable[CancelledDate] >= __selectedDate
                        || ISBLANK ( UserTable[CancelledDate] )
                )
                && UserTable[UserStatus] = "Active"
        ),
        UserTable[UserId]
    )

22012604.jpg

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

lbendlin
Super User
Super User

Please provide sanitized sample data that fully covers your issue. Paste the data into a table in your post or use one of the file services. Please show the expected outcome.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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.

Top Solution Authors