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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ERing
Helper V
Helper V

How to return only records for a date between two other dates?

I have data like below where each work order has an Start_Date, In_Progress_Date, and End_Date. My requirement is a report where there is a slicer for the Start_Date and  slicer for the End_Date and the table visual shows only records with an In_Progress_Date between the Start_Date and End_Date.

 

In the example where the user selects a Start_Date of 09/30/23 and an End_Date of 11/01/23, work orders 9 & 10 would be excluded because the In_Progress_Date falls on or before the Start_Date or on or after the End_Date.

 

Work_Order_IDStart_DateIn_Progress_DateEnd_Date
19/30/202310/1/202311/1/2023
29/30/202310/2/202311/1/2023
39/30/202310/3/202311/1/2023
49/30/202310/4/202311/1/2023
59/30/202310/5/202311/1/2023
69/30/202310/6/202311/1/2023
79/30/202310/7/202311/1/2023
89/30/202310/8/202311/1/2023
99/30/20239/30/202311/1/2023
109/30/202311/1/202311/1/2023
1 ACCEPTED SOLUTION
v-xuxinyi-msft
Community Support
Community Support

Hi @ERing

 

I ran the following test.

 

1. Create two slicer table

vxuxinyimsft_0-1705649824703.png

 

vxuxinyimsft_1-1705649844593.png

 

2. Create a measure as follows

 

Measure = 
IF( 
    SELECTEDVALUE('Table'[In_Progress_Date]) > SELECTEDVALUE(startdate[Date]) 
    && SELECTEDVALUE( 'Table'[In_Progress_Date]) < SELECTEDVALUE(endstart[Date]),
    1,
    0
)

 

 

Put the measure into the filter so that the visual only shows data where the measure is equal to 1.

vxuxinyimsft_0-1704691559813.png

 

vxuxinyimsft_3-1705649967242.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Yuliax

 

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

4 REPLIES 4
v-xuxinyi-msft
Community Support
Community Support

Hi @ERing

 

I ran the following test.

 

1. Create two slicer table

vxuxinyimsft_0-1705649824703.png

 

vxuxinyimsft_1-1705649844593.png

 

2. Create a measure as follows

 

Measure = 
IF( 
    SELECTEDVALUE('Table'[In_Progress_Date]) > SELECTEDVALUE(startdate[Date]) 
    && SELECTEDVALUE( 'Table'[In_Progress_Date]) < SELECTEDVALUE(endstart[Date]),
    1,
    0
)

 

 

Put the measure into the filter so that the visual only shows data where the measure is equal to 1.

vxuxinyimsft_0-1704691559813.png

 

vxuxinyimsft_3-1705649967242.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Yuliax

 

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

AmiraBedh
Resident Rockstar
Resident Rockstar

Try the following : 

 

Filtered Work Orders = 
CALCULATE(
    COUNTROWS('YourTableName'),
    FILTER(
        'YourTableName',
        'YourTableName'[In_Progress_Date] > MAX('YourTableName'[Start_Date]) &&
        'YourTableName'[In_Progress_Date] < MIN('YourTableName'[End_Date])
    )
)

Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Hi @AmiraBedh I'm not looking to return a count. I need to be able to show a table visual with the results. In this case I want my table visual to exclude the last two rows. 

 

A calculated column maybe ?

 

Is Within Date Range = 
IF(
    AND(
        'YourTableName'[In_Progress_Date] > SELECTEDVALUE('YourTableName'[Start_Date]),
        'YourTableName'[In_Progress_Date] < SELECTEDVALUE('YourTableName'[End_Date])
    ),
    1,
    0
)

Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.