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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
RKi
Frequent Visitor

Filtering records DateFrom >= ReferenceDate and the ReferenceDate<=DateTo

Hi,

 

As reletavily new to Power BI I come up with the next problem (I'll try to expain it simple) :

I have a table "X" with four columns: PatientKey, Categorie, DateFrom and DateTo.

It contains data about the Categorie of the patient. For example Categorie "R" = Regular, "M"= Moved away.

So a patient can have multiple entries.

 

Now what I want in my dashboard is to type in a reference date and based on that date select the records where the DateFrom >= ReferenceDate and the ReferenceDate<=DateTo.

 

Anyone an idea?

 

Thx,

Rki

 

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

Hi @RKi ,

 

First you need to introduce a custom visual for the Text search slicer:

Text search slicer

 

Then we need create a new date table for the silcer. Since the Text search slicer accepts values of text type, here I have added a new calculated column:

vcgaomsft_0-1719295958695.png

Here you can also format the date to the customer's preferred format, I demonstrated here is "YYYYMMDD".

 

Then create a new measure for the visual‘s filter:

Measure = 
VAR __input = SELECTEDVALUE('Date'[Date])
VAR __cur_date_from = SELECTEDVALUE('Table'[DateFrom])
VAR __cur_date_to = SELECTEDVALUE('Table'[DateTo])
VAR __result = IF( ISBLANK(__input) || (__cur_date_from <= __input && __cur_date_to >= __input), 1)
RETURN
__result

result:

vcgaomsft_1-1719296176544.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group



View solution in original post

2 REPLIES 2
v-cgao-msft
Community Support
Community Support

Hi @RKi ,

 

First you need to introduce a custom visual for the Text search slicer:

Text search slicer

 

Then we need create a new date table for the silcer. Since the Text search slicer accepts values of text type, here I have added a new calculated column:

vcgaomsft_0-1719295958695.png

Here you can also format the date to the customer's preferred format, I demonstrated here is "YYYYMMDD".

 

Then create a new measure for the visual‘s filter:

Measure = 
VAR __input = SELECTEDVALUE('Date'[Date])
VAR __cur_date_from = SELECTEDVALUE('Table'[DateFrom])
VAR __cur_date_to = SELECTEDVALUE('Table'[DateTo])
VAR __result = IF( ISBLANK(__input) || (__cur_date_from <= __input && __cur_date_to >= __input), 1)
RETURN
__result

result:

vcgaomsft_1-1719296176544.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group



Thx for your solution. It works fine!!!

 

Great job

 

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors
Top Kudoed Authors