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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Jan03
New Member

Dynamic Complex Filtering with slicers

Hello, I have a question.

I am learning Power BI and I want to implement dynamic filtering based on user interaction within the dashboard.

Specifically, I need the user to select a date from a list, and then have that selected date used internally to perform a calculation: adding one month to it.

After that calculation, the resulting date needs to be compared against two fields in a fact table: Fecha and Vencimiento. The logic should work as follows:

 

  • The selected date plus one month must be greater than or equal to the Vencimiento field.
  • It must also be less than the Fecha field. This would allow me to filter all records in the fact table that meet those conditions.

The idea is to show in different graphics all of the registers that satisfy the condition described before. I initially tried to accomplish this using slicers, but from what I’ve tested so far, slicers only filter directly by fields. In other words, I haven’t been able to create more complex or computed filters using slicers alone.

8 REPLIES 8
cengizhanarslan
Super User
Super User

1) Create a slicer table (disconnected)

Use a date table just for the slicer (it must not relate to the fact table):

SlicerDate =
CALENDAR ( DATE(2020,1,1), DATE(2035,12,31) )

Put SlicerDate[Date] on a slicer.

 

2) Create a measure that flags valid fact rows

InRange (row) =
VAR SelDate = SELECTEDVALUE ( SlicerDate[Date] )
VAR SelPlus1 = EDATE ( SelDate, 1 )
VAR Venc = MIN ( Fact[Vencimiento] )
VAR Fec  = MIN ( Fact[Fecha] )
RETURN
IF (
    NOT ISBLANK ( SelDate )
        && SelPlus1 >= Venc
        && SelPlus1 < Fec,
    1,
    0
)

 

3) Apply it to visuals

For each visual you want to filter:

  • Drag InRange (row) into the visual-level filters

  • Set it to is 1

This will make the visual only show records where:

SelectedDate + 1 month >= Vencimiento and SelectedDate + 1 month < Fecha

_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn
AI-assisted tools are used solely for wording support. All conclusions are independently reviewed.

Thanks, but it doesnt work. I did exactly what you said. Probably i made a mistake in the medium steps. And the problem isn't the data.

Jan03_0-1769706477571.pngJan03_1-1769706508610.png

Jan03_3-1769706588447.png

 

 

I think the only issue is that your initial variable is potentially pointed to the calendar table that has a relationship to the fact table and not the disconnected SlicerDate[Date] table you created for the slicer.

-----------------------
Did this help?
Drop a kudo so others can find it ! 😄
Mark as a solution if it helped you make progress on your issue 😃

I cant see a relationship between tables. The calendar table (which creates the slicer) is apart.

Jan03_0-1769707660847.png

 

Ashish_Mathur
Super User
Super User

Hi,

I have solved a similar question in the attached file.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
d_m_LNK
Super User
Super User

Hi There!

Please consider this solution:

 

Step 1: Create a disconnected Calendar table in your data model All the calendar references in these measures must be to the disconnected table

 

Step 2 Date Slicer: Use the Drop Down slicer style with your date field but add other fields to make selection easier. Add Year, Quarter, Month, Date to the fields section of the date slicer and this will allow you to pick a specific date.

d_m_LNK_0-1769553847984.png

 

Step 3 Measure to select the date:  Create a measure like this:

Selected Date = Max(Calendar[date])  --this grabs the max date in the selected context

 

Step 4 Add Date Measure:

AddOneMonth = 

VAR _DateSelected = [SelectedDate]
VAR _AddOneMonth = CALCULATE( DATEADD( Calendar[Date], 1, MONTH ), Calendar[Date] = _DateSelected )

RETURN _AddOneMonth

 

Step 5 Criteria Measure:

MeetsCriteria =
SWITCH(TRUE(),
Table[Fecha] > [AddMonthToSelected] && Table[Vencimiento]< [AddMonthToSelected],
1, 0
)

 

Step 6: Add this column to your table visual and use the filter pane to filter to the value you are desiring

 

-----------------------
Did this help?
Drop a kudo so others can find it ! 😄
Mark as a solution if it helped you make progress on your issue 😃

Thats the thing i wanted, but im having trouble with the step 5. The column you described at the step 5 is always false. Probably i did one of the previous steps wrong, but the measure of the steps 3 and 4 with its respective value seems okay, their values update in real time when i choose one or other option in the slicer. 

Jan03_0-1769632459468.png

 

Make sure that the correct comparisons are happening for the correct table.  Also I think I forgot something in the last measure:
MeetsCriteria =
SWITCH(TRUE(),
SelectedValue(Table[Fecha]) > [AddMonthToSelected] && SelectedValue(Table[Vencimiento])< [AddMonthToSelected],
1, 0
)

-----------------------
Did this help?
Drop a kudo so others can find it ! 😄
Mark as a solution if it helped you make progress on your issue 😃

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.