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

Measure for days around SELECTEDVALUE

Hello,

 

I'm trying to create a measure to apply a filter for the dates around a selected date in a date table ('Date Table') based on a selected date in the filter.

 

Functionally i would like to have it as either a 1 or a 0 to apply the filter on if the date is +/- 3 days on either side of the slicer. So if the chosen date is Jan 10, 2020, i would like the measure to be 1 for Jan 7, 2020 to Jan 13, 2020, and all other dates in the table to be 0. In the base case of no selection i would probably just want it to be a 1 if possible. My hope is to have this as a measure within the 'Date Table' so i can just pop this into other pages as required.

 

Any suggestions? I can get the selected value with SELECTEDVALUE, but its the application of the 1/0 thats got me stumped for the measure side.

 

thanks!

3 REPLIES 3
wdx223_Daniel
Super User
Super User

@cody_s think you need to date table, the table on slicer should have not relationship, then put one in the slicer, another one in your visual, like this

wdx223_Daniel_0-1608613665683.png

 

amitchandak
Super User
Super User

@cody_s , Try a measure like

 

new measure =
var _max = maxx(allselected('Date'),'Date'[Date])+3
var _min = maxx(allselected('Date'),'Date'[Date])-3
return
calculate( sum(Table[Value]), filter(all(Date),'Date'[Date] >=_min && 'Date'[Date] <=_max))

Thats not quite the solution that i'm thinking of. I'm thinking of a measure thats either 1 or 0 so i can apply it as a filter on my table as an "equals 1"

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.

Top Solution Authors