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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
jcamilo1985
Helper III
Helper III

cancel slicer dates

First of all, thank you so much to everyone who takes the time to read this post.

I have the following scenario: two calendar tables. The first (calendar1) is connected to the fact table via the `fecha_radicacion` field, and the second (calendar2) is connected to the `fecha_solucion` field. Both are active with a one-to-many relationship.

In the Power BI canvas, I have a slicer with the date from `calendar1`. This slicer is configured to accept only one date. The desired behavior is for the visual to show the seven days prior to the date selected in the slicer, and if no date is selected, to return the seven days prior to today. The measures section should include two calculations: the first is the count of rows in the fact table based on the `fecha_radicacion` date, and the second is the count of rows based on the `fecha_solucion` date. For example, suppose we have selected the date 10-02-2026, the visual should then display dates from 3-02-2026 to 9-02-2026. The first calculation will simply count the rows from the fact table, but the second calculation should count the rows from the fact table for the specific date, only by the date of the solution_date without being restricted by the filing_date.

 

imagen.png

 

 

I've attached an image of what I tried with keepfilters to intersect the dates, but it's not working.

I appreciate any help you can provide.

 

 

1 ACCEPTED SOLUTION
cengizhanarslan
Super User
Super User

Step 1) Helper: Selected date (or today) and the 7-day window

_Selected Date =
COALESCE ( SELECTEDVALUE ( calendar1[Fecha] ), TODAY() )

_In Window =
VAR Cutoff = [_Selected Date]
VAR StartD = Cutoff - 7
VAR EndD   = Cutoff - 1
VAR ThisD  = MAX ( calendar1[Fecha] )
RETURN
IF ( ThisD >= StartD && ThisD <= EndD, 1, 0 )

Put "_In Window" in the visual-level filters and keep only = 1. This makes the table show only the 7 days prior.

 

Step 2) Count by fecha_radicacion (calendar1)

Orders (Radicacion) =
VAR Cutoff = [_Selected Date]
VAR StartD = Cutoff - 7
VAR EndD   = Cutoff - 1
RETURN
CALCULATE (
    COUNTROWS ( Fact ),
    REMOVEFILTERS ( calendar1[Fecha] ),
    DATESBETWEEN ( calendar1[Fecha], StartD, EndD )
)

 

Step 3) Count by fecha_solucion (calendar2) without being restricted by filing date

Orders (Solucion) =
VAR DatesOnAxis = VALUES ( calendar1[Fecha] )
RETURN
CALCULATE (
    COUNTROWS ( Fact ),
    REMOVEFILTERS ( calendar1 ),
    TREATAS ( DatesOnAxis, calendar2[Fecha] )
)

 

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

View solution in original post

6 REPLIES 6
danextian
Super User
Super User

Hi @jcamilo1985 

 

As what @hnguy71 has suggested, one of the calendar tables has to be disconnected. Filters from a related or the same table will show only  the rows selected. Functions that modify the filter context can only override the value being returned by a measure but not the visible rows. 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Thanks for replying.

cengizhanarslan
Super User
Super User

Step 1) Helper: Selected date (or today) and the 7-day window

_Selected Date =
COALESCE ( SELECTEDVALUE ( calendar1[Fecha] ), TODAY() )

_In Window =
VAR Cutoff = [_Selected Date]
VAR StartD = Cutoff - 7
VAR EndD   = Cutoff - 1
VAR ThisD  = MAX ( calendar1[Fecha] )
RETURN
IF ( ThisD >= StartD && ThisD <= EndD, 1, 0 )

Put "_In Window" in the visual-level filters and keep only = 1. This makes the table show only the 7 days prior.

 

Step 2) Count by fecha_radicacion (calendar1)

Orders (Radicacion) =
VAR Cutoff = [_Selected Date]
VAR StartD = Cutoff - 7
VAR EndD   = Cutoff - 1
RETURN
CALCULATE (
    COUNTROWS ( Fact ),
    REMOVEFILTERS ( calendar1[Fecha] ),
    DATESBETWEEN ( calendar1[Fecha], StartD, EndD )
)

 

Step 3) Count by fecha_solucion (calendar2) without being restricted by filing date

Orders (Solucion) =
VAR DatesOnAxis = VALUES ( calendar1[Fecha] )
RETURN
CALCULATE (
    COUNTROWS ( Fact ),
    REMOVEFILTERS ( calendar1 ),
    TREATAS ( DatesOnAxis, calendar2[Fecha] )
)

 

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

Thanks for replying.
I didn't get a chance to test this solution; Copilot marks it as the solution path.
However, what I did to work around it was create an additional calendar table, really just the date column. I linked this table using an active relationship to the filing date and an inactive relationship to the resolution date. I use these dates in the visual editor, then in DAX, with the active context of the main dates table, I create a small table with the dates I need. Then, using CALCULATE, I remove the filters from the other tables and pass the previously created table, and voila!

The new calendar table is small, so it doesn't impact storage or performance.

hnguy71
Super User
Super User

Hi @jcamilo1985 

 

I suggest you disconnect your second date table similar to this:

hnguy71_0-1772586998603.png


Then, on your page slicer or filter pane, use the date from the disconnected table to retrieve user input. So your updated measure would look something like this instead:

__prueba =

// return the user's selected date
VAR _filtrado = SELECTEDVALUE('Select Dates'[Date])

// return data based on date range
VAR _fechas = CALCULATE(YOUR_MEASURE_OR_EVALUATION, calendario[Fecha] >= _filtrado - 7 && calendario[Fecha] < _filtrado)


RETURN

_fechas

 

This works because you're not relying on a relationship to return the user input and simplifies your DAX expression.



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Thanks for replying.
I didn't get a chance to test this solution; Copilot marks it as the solution path.
However, what I did to work around it was create an additional calendar table, really just the date column. I linked this table using an active relationship to the filing date and an inactive relationship to the resolution date. I use these dates in the visual editor, then in DAX, with the active context of the main dates table, I create a small table with the dates I need. Then, using CALCULATE, I remove the filters from the other tables and pass the previously created table, and voila!

The new calendar table is small, so it doesn't impact storage or performance.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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