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
GKJARC
Resolver I
Resolver I

Showing rows in table visual depending on selected date range

Hi!

 

In a table visual, I'm trying to show only the rows where there is an overlap between the ValidFrom to ValidTo, and the selected date range.
The Date in the date range slicer comes form an unrelated calendar table.

 

GKJARC_1-1642523831957.png

 

So with the above selected date range, only the rows marked here as '1' should appear in the table visual in Power BI:

 

GKJARC_2-1642524295451.png

 

The first 4 columns all come from a single table.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@GKJARC , Try a measure like

Measure =
VAR _min = MINX(allselected(Dates) ,Dates[Date])
VAR _max = MAXX(allselected(Dates) ,Dates[Date])
return
if(max(Table[Valid From]) <= _max && max(Table[Valid To]) >=_min , 1,0)+0

 

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@GKJARC , Try a measure like

Measure =
VAR _min = MINX(allselected(Dates) ,Dates[Date])
VAR _max = MAXX(allselected(Dates) ,Dates[Date])
return
if(max(Table[Valid From]) <= _max && max(Table[Valid To]) >=_min , 1,0)+0

 

Thanks @amitchandak , that seems to work!
I used SWITCH-statements intstead of IF-statement hoping to improve performance since I have 3 conditions, and the table visual that this measure applies to is relatively large.
When I add the measure as a filter on the table visual level (Measure <> 0), then Power BI can handle it in terms of memory.

One more question, what is the function of the +0 at the end of the measure?

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.