Filter based on Conditions for Dates

Hello

I have the following requirement for one of my report.

  • There is a date filter based on a date table in the filter panel,
  • There is a relationship based on the Date Table [Date] and “Table”[Date T]

The user want to be able to select a date from the panel and the table must return the transactions with Date T<= Selected Date and Date 2 >= Selected Date.

My Tab “Expected result” shows what I expect to find if I select Oct 3rd in my filter panel.

Eventually, I can slightly modify my report and put the DateTable[Date] field as a slicer in my canvas.

I have been working for a couple of days now without finding a satisfying option. So if anyone could help me find “the” solution it would be greatly appreciated.

Thanks a lot

Cedric
25102022.pbix (59.8 KB)

Hi @Cedric. I downloaded your PBIX but don’t see an “Expected result” page. Can you add a screenshot or upload the file containing this page? Greg

Hello Greg thank you so much for your time.
Please find this version of the file.

Thanks again.
25102022.pbix (72.5 KB)

Hi @Cedric

I’m still unclear of what you’re expecting. I do see the “Expected result” page now, but unfortunately it just contains the same text as your post. Please prepare a screenshot mockup (in Excel?) of what you are expecting to assist the forum members in their investigations.

Greg

Hi Greg, Please find the attached excel file.

As illustrated if I select October 3rd in my filter pane, I would like my table to automatically display transactions with a Date T inferior or equal to the selected date (Oct 3rd) and with a Date 2 superior or equal to the selected date.
I’ve applied manual filters to the table for the moment just to show what my expected result is but would the goal is to find a dax formula instead of having to deal with filters on the visual.

Thank you,
251022.xlsx (365.8 KB)

Hi @Cedric.

As with many things in Power BI, there are multiple ways to address your isssue.

Here’s the steps I took for my solution:

  • marked [Date] table as a dates table
  • deleted relationship between Date[Date] and Table[Date 2]
  • added slicer for Date[Date], no slider, set to “After”, covered second input with blank rectangle
  • updated [Selected Date] measure to harvest selected date value
  • added [Is Date T before] and [Is Date 2 after] measures
  • added [Is Date T before] and [Is Date 2 after] measures into filter pane for “Accounts” table

Here’s the DAX code for the 2 simple data check measures:

Is Date T before = IF( MAX( 'Table'[Date T] ) <= [Selected Date], 1, 0 )

Is Date 2 after = IF( MAX( 'Table'[Date 2] ) >= [Selected Date], 1, 0 )

Hope this helps.
Greg
eDNA Forum - Filter Based on Condition for Dates.pbix (68.3 KB)

1 Like

Thank you very much Gregg this is really appreciated.

I will review you it and keep you posted.

Best regards,

Cédric

Hello @Cedric ,

Did the response above help solve your query?

If not, can you let us know where you’re stuck and what additional assistance you need? If it did, please mark the solution that helped you.

Thank you

Hi @Cedric ,

Due to inactivity, a response on this post has been tagged as “Solution”. If you have a follow question or concern related to this topic, please remove the Solution tag first by clicking the three dots beside Reply and then untick the check box.

Thanks to the contributors of this post.

We request you to kindly take time to answer the Enterprise DNA Forum User Experience Survey,

We hope you’ll give your insights on how we can further improve the Support forum. Thanks!