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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Filter a visual according to the selected date.

Hello,

 

I have the following problem, I need to filter a visual so that it shows me only the results of the selected dates. Does anyone know how I could do it?

 

I have the following metric that works correctly, but I need to apply it to a visual that returns TRUE or FALSE if it is in that date range, but I can't do it.

 

Test =
VAR minDate =
MIN ( 'Dim_Calendar'[Date] )
VAR maxDate =
MAX ( 'Dim_Calendar'[Date] )
RETURN
CALCULATE (
SUM ( 'tableA'[A] ),
FILTER (
Dim_1,
Dim_1[Start Date] <= maxDate
&& Dim_1[End Date] >= minDate
),
FILTER (
Dim_2,
Dim_2[Start Date] <= maxDate
&& Dim_2[End Date] >= minDate
)
)

 

Thanks!

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , Try like

 

Test =
VAR minDate =
MINX ( allselected('Dim_Calendar'),'Dim_Calendar' [Date] )
VAR maxDate =
MAXX ( allselected('Dim_Calendar'),'Dim_Calendar' [Date] )
RETURN
CALCULATE (
SUM ( 'tableA'[A] ),
FILTER (
Dim_1,
Dim_1[Start Date] <= maxDate
&& Dim_1[End Date] >= minDate
),
FILTER (
Dim_2,
Dim_2[Start Date] <= maxDate
&& Dim_2[End Date] >= minDate
)
)

 

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Anonymous
Not applicable

Hi @amitchandak 

It doesn't work as what I need is to filter only the display (table). The value it shows is correct but it brings me several records, what I need is for it to show me only the record that includes that date, that's why it seems to me that what I need is a value of TRUE or FALSE as a result to add it to the visualization .

 

Thanks!

Hi @Anonymous,

Perhaps you can try to create a filter that is not related to the fact table and use the measure on 'visual level filter' to filter records.

Applying a measure filter in Power BI - SQLBI

If the above is not help, can you please share a pbix or some dummy data that keep raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.