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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
v_mark
Helper V
Helper V

14 days before and after a selected date

I was trying to wrap my head around this requirement.

So the idea is once a user select a date ( w/c in this case a single select only ) 

 

A graph a line chart or bar chart maybe will show the 14 days before and after sales. 

Been trying to search for a solution in the web w/c I saw from EDNA (5) Show Days Before Or After A Selected Date - Advanced Power BI Visual Techniques - YouTube but I think this covers only before ( I might be wrong ) 

 

Is there any leads or Info how I can achieve before and after in one single visual? 


Here is the sample Pbix


TIA

5 REPLIES 5
Anonymous
Not applicable

Hi @v_mark ,

 

You will need to create an independent date slicer table. If you use date column from original table, once the slicer being selected, the visual will only show selected date's value.

I'd like to suggest you to create a measure like below and add it to visual filter set value = 1.

 

measure = IF(selectedvalue('table'[date])>selectedvalue('slicer'[date])-14&&selectedvalue('table'[date])<selectedvalue('slicer'[date])+14,1,0)

 

 

Best Regards,

Jay

v_mark
Helper V
Helper V

@amitchandak - From what I understand this Independent Date table needs to be disconnected on the main Date Table. Is there a way to use a date filter coming from the main date table. to use as a filter?

v_mark
Helper V
Helper V

Thank you @Aburar_123 and @amitchandak.  I'm sorry Seems like the pbix sample is not uploaded when I made the post. 
I re-edit with the sample pbix. 

Aburar_123
Solution Supplier
Solution Supplier

Hi @v_mark,

 

Please follow the below steps,

 

1. Create a Date table

Dim_date = CALENDAR(min('Sales SalesOrderHeader'[OrderDate]),MAX('Sales SalesOrderHeader'[OrderDate]))
2. Create another Date table
Dim_date_Independant = CALENDAR(min('Sales SalesOrderHeader'[OrderDate]),MAX('Sales SalesOrderHeader'[OrderDate]))
3. Create below three measures
Start_Date = max(Dim_date_Independant[Date])-14
End_Date = max(Dim_date_Independant[Date])+14
Date_range_flag = IF(MAX(Dim_date[Date])>='Measure Table'[Start_Date] && MAX(Dim_date[Date])<='Measure Table'[End_Date],1,0)
4. Create date slicer from Dim_date_Independant table
5. Create join between 'Sales SalesOrderHeader'[OrderDate] and Dim_date[Date]
6. Create a bar graph with X-axis is Dim_date[Date] and 'Sales SalesOrderHeader'[Profit] and place the Date_range_flag=1 in the visual level filter.
 
Aburar_123_0-1648446874974.png

 

 

 

Please Mark my post as a Solution if it solves your Problem. Thanks

amitchandak
Super User
Super User

@v_mark , I think you need and independent date table for that

 

//Date1 is independent Date table, Date is joined with Table
new measure =
var _max1 = maxx(allselected(Date1),Date1[Date])
var _min = _max1  -14

var _min =_max1 + 14
return
calculate( sum(Table[Value]), filter('Date', 'Date'[Date] >=_min && 'Date'[Date] <=_max))

 

Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.