Forum Discussion
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
i found a slution , create a new calander table completely separt no relationships
create a measureFiltering = 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 measureLine Chart Sales = CALCULATE([Sales],REMOVEFILTERS(Calander[Date]),Calander[Date] = MAX('Calander Inactive'[Date]))
1 Reply
- eliasayyyMemorable Member
i found a slution , create a new calander table completely separt no relationships
create a measureFiltering = 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 measureLine Chart Sales = CALCULATE([Sales],REMOVEFILTERS(Calander[Date]),Calander[Date] = MAX('Calander Inactive'[Date]))