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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. 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
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.