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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.