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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
eliasayyy
Memorable Member
Memorable Member

Create line chart based on filtering date

Hello everyone, 

i have a slicer that seelcts week number

i have a line chart , x-axis is date and y-axis is total sales

i created a measure to calculate last week sales called Previous week sales

today is Friday 28 april 2023 which is week 18

week 18 starts from monday 24 2023 and ends sunday 30 2023

week 17 starts monday 17 2023 and ends sunday 23 2023

if i selected week 18 on my slicer

i want the line chart to return dates from monday 17 to max date which is sunday 23

how can i achieve this?

@tamerj1 @johnt75 @FreemanZ @amitchandak 

1 ACCEPTED SOLUTION
eliasayyy
Memorable Member
Memorable Member

i found a slution , create a new calander table completely separt no relationships

create a measure 

Filtering = 
VAR selectedweek = MAX(Calander[Week ID])
VAR lastweek = selectedweek - 1
VAR weekstart = CALCULATE(MIN(Calander[Date]),REMOVEFILTERS(Calander[Date]),Calander[Week ID] = lastweek)
VAR weekend = MAX(Calander[Date])
VAR result = IF(AND(MIN('Calander Inactive'[Date]) >= weekstart, MAX('Calander Inactive'[Date]) <= weekend), 1, 0)
RETURN
result


add the date from seperate calendar table to line chart on x-axis

create a new measure

Line Chart Sales = CALCULATE([Sales],REMOVEFILTERS(Calander[Date]),Calander[Date] = MAX('Calander Inactive'[Date]))

View solution in original post

1 REPLY 1
eliasayyy
Memorable Member
Memorable Member

i found a slution , create a new calander table completely separt no relationships

create a measure 

Filtering = 
VAR selectedweek = MAX(Calander[Week ID])
VAR lastweek = selectedweek - 1
VAR weekstart = CALCULATE(MIN(Calander[Date]),REMOVEFILTERS(Calander[Date]),Calander[Week ID] = lastweek)
VAR weekend = MAX(Calander[Date])
VAR result = IF(AND(MIN('Calander Inactive'[Date]) >= weekstart, MAX('Calander Inactive'[Date]) <= weekend), 1, 0)
RETURN
result


add the date from seperate calendar table to line chart on x-axis

create a new measure

Line Chart Sales = CALCULATE([Sales],REMOVEFILTERS(Calander[Date]),Calander[Date] = MAX('Calander Inactive'[Date]))

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.