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
MariKo
Frequent Visitor

PowerBI Date slicer on a period between Start and End dates

I am trying to set up a date range filter in order to filter a table with Start and End Dates on certain user-related data. For example, I set up a filter between 22/10/2016 and 06/10/2022 and the table is filtered on all records between these dates based on Start and End Date in the table. In my case, the table does not show exactly what I want since the first line in the table starts on 01/01/2006. My idea that in this case the table shows all lines except the first one.

7e980689-d757-4d57-a6a2-8ec539f7d18c.png

 

USER IDType NameTypeStart DateEnd DateDate Included
0001Contract031 January 200631 December 2019Include

0001

Contract041 January 20207 October 2022Include
0002Contract

01

30 June 201731 December 2019Include
0002Contract021 January 20207 October 2022Include
0003Contract011 August 20217 October 2022Include

 

I have also used the DAX measures like

 

Date Included = 
  IF (
FIRSTNONBLANK ( DATA[Start Date], 1 ) <= MAX ( 'Calendar'[Date] ) &&
FIRSTNONBLANK(DATA[End Date], 1 ) >= MIN ( 'Calendar'[Date] ),
"Include",
"Exclude"
  )

and

isShown = 
   IF (
ISFILTERED ( 'Calendar'[Date]),
IF (
    MAX ( 'Calendar'[Date]) >= MAX ( 'DATA'[Start Date] )
        && MAX ( 'Calendar'[Date] ) <= MAX ( 'DATA'[End Date] ),
    1,
    BLANK ()
),
1
 )

with the View Filtering but it does not work. My data consists of a Calendar table and Data table. There are no relationships between the Calendar and Data tables in the model.

Any help would be appreciated! Thank you.

1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @MariKo ,

 

Please try this measure:

Date Include = IF(MIN('Calendar'[Date])<=MAX('Table'[Start Date])&&MAX('Calendar'[Date])>=MAX('Table'[End Date]),"Include","Exclude")

vstephenmsft_0-1665468649867.png

Because October 7, 2022 in the end date is outside of October 6, 2022, the maximum date of the slicer, the result I give is also excluded. What logic is it that you only want to show all but the first row? Please describe it in more detail.

 

 

Best Regards,

Stephen 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

2 REPLIES 2
v-stephen-msft
Community Support
Community Support

Hi @MariKo ,

 

Please try this measure:

Date Include = IF(MIN('Calendar'[Date])<=MAX('Table'[Start Date])&&MAX('Calendar'[Date])>=MAX('Table'[End Date]),"Include","Exclude")

vstephenmsft_0-1665468649867.png

Because October 7, 2022 in the end date is outside of October 6, 2022, the maximum date of the slicer, the result I give is also excluded. What logic is it that you only want to show all but the first row? Please describe it in more detail.

 

 

Best Regards,

Stephen Tao

 

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

 

Hi, @v-stephen-msft . Thank you for your answer. You solution worked. My logic was to filter on the date range (start date - end date) that fall within the slicer choice. 

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.