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

Slicer with 2 date fields

Hi, 

  I have the following sample:

 

  Creation_date | Finish_Date | Responsible
  09/01/2022     | 09/05/2022 | John Doe
  09/05/2022     | 09/10/2022 | Mary
  09/10/2022     | 09/15/2022 | Peter

 

I need to create a slicer to filter the date based on fields Creation_date and Finish_date. The idea is like a OR clause: if the selected date is between Creation_date OR Finish_Date the data must be filtered. 

 

Based on the data sample, if I choose the Date 09/05/2022 the two first lines should be filtered.

 

I found many samples using the USERELATIONSHIP function, but I could not get how to use it with my situation. USERELATIONSHIP example are always based on specific measures, but here I need to get all data filtered.

 

Please, Any ideas?

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

Hi, @lguima ;

You need create another date table.

Date = UNION(VALUES('Table'[Creation_date]),VALUES('Table'[Finish_Date]))

Then create a flag measure.

flag = IF(MAX('Table'[Creation_date]) in VALUES('Date'[Creation_date])||MAX('Table'[Finish_Date]) in VALUES('Date'[Creation_date]),1)

Then setting it.

vyalanwumsft_0-1664158027545.png

The final show:

vyalanwumsft_1-1664158049989.png


Best Regards,
Community Support Team _ Yalan Wu
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

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-yalanwu-msft
Community Support
Community Support

Hi, @lguima ;

You need create another date table.

Date = UNION(VALUES('Table'[Creation_date]),VALUES('Table'[Finish_Date]))

Then create a flag measure.

flag = IF(MAX('Table'[Creation_date]) in VALUES('Date'[Creation_date])||MAX('Table'[Finish_Date]) in VALUES('Date'[Creation_date]),1)

Then setting it.

vyalanwumsft_0-1664158027545.png

The final show:

vyalanwumsft_1-1664158049989.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

jthomson
Solution Sage
Solution Sage

What you might need to do is create a separate table which has the primary key of this table, and then expands every date between your creation date and finish date fields into a new row (i.e. for your first line, there would be five rows with each of the first five days of this month in them). Relate that to your main data table, and have the slicer look at the new table. This should then allow you to get what you want

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.