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

Filter a table using the previous 15 days of the date of the currently selected row

I have two tables. A and B. I want table B to show the detail corresponding to the previous 15 days from the date of the selected row in table A. For example, if I select a row in the table A with the date 2023-20-01, the table B should show the details from 2023-05-01, to 2023-19-01. I've tried different approaches but nothing worked. I'd appreciate any help or hint on the subject. Thanks in advance!

IMG-20240118-WA0004.jpg

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

Hi @Agustinms ,

 

I am not sure if I understood your question correctly.
It sounds like you are using TableB to show the results after filtering in TableA.
Based on my understanding above, here is the data I created from the sample you provided.
TableA:

vweiyan1msft_0-1705913750145.png

1.You can create a calcualted table.

 

Date = VALUES('TableA'[Date])

 

vweiyan1msft_1-1705913781345.png

2. Use the following code to create a Measure.

 

Previous 15 Days Filter = 
VAR _selectedDate = SELECTEDVALUE ( 'Date' [Date] )
VAR _startDate = _selectedDate - 15
VAR _endDate = _selectedDate - 1
RETURN
IF ( MAX('TableA'[Date]) >= _startDate && MAX('TableA'[Date]) <= _endDate, 1, 0 )

 

3. Select your visual object, put the measure in the “Filters on this visual” section, and filter it by “Measure is 1”.

vweiyan1msft_2-1705913833329.png

The field of the slicer is from Date Table. When you select "1/20/2023" in the slicer, Result is as below.

vweiyan1msft_3-1705913945508.png

 

Is this the result you expect?
Please correct me if I misunderstood your needs.

 

Best Regards,
Yulia Yan

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-weiyan1-msft
Community Support
Community Support

Hi @Agustinms ,

 

I am not sure if I understood your question correctly.
It sounds like you are using TableB to show the results after filtering in TableA.
Based on my understanding above, here is the data I created from the sample you provided.
TableA:

vweiyan1msft_0-1705913750145.png

1.You can create a calcualted table.

 

Date = VALUES('TableA'[Date])

 

vweiyan1msft_1-1705913781345.png

2. Use the following code to create a Measure.

 

Previous 15 Days Filter = 
VAR _selectedDate = SELECTEDVALUE ( 'Date' [Date] )
VAR _startDate = _selectedDate - 15
VAR _endDate = _selectedDate - 1
RETURN
IF ( MAX('TableA'[Date]) >= _startDate && MAX('TableA'[Date]) <= _endDate, 1, 0 )

 

3. Select your visual object, put the measure in the “Filters on this visual” section, and filter it by “Measure is 1”.

vweiyan1msft_2-1705913833329.png

The field of the slicer is from Date Table. When you select "1/20/2023" in the slicer, Result is as below.

vweiyan1msft_3-1705913945508.png

 

Is this the result you expect?
Please correct me if I misunderstood your needs.

 

Best Regards,
Yulia Yan

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

Yes! I tested the uploaded pbix and the result is what I was looking for. I tried using measures, but it didn't work for some reason. I'll try to replicate this in my report. Thank you very much for taking the time!!

lbendlin
Super User
Super User

You use disconnected tables and measures as visual filters.

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Thanks for the advice. I already got a solution in a comment, but I'll keep this in mind for posts in the future!

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.