Forum Discussion
Filtering Active Contracts Over a Period
Hey there!
Since the dataset contains contracts for multiple years, we need a year filter table.
Years = DISTINCT(YEAR(all_contracts[Date])) (This table will allow users to select a start year and end year.)
Then add two slicers using the Year table: One for Start Year. One for End Year.
Now, define a measure that ensures only contracts within the selected range are displayed using DAX:
Filtered Contracts =
VAR StartYear = SELECTEDVALUE(Years[Year])
VAR EndYear = SELECTEDVALUE(Years[Year], MAX(all_contracts[Date]))
RETURN
CALCULATE(
SUM(all_contracts[contract_value]),
FILTER(
all_contracts,
YEAR(all_contracts[Date]) >= StartYear &&
YEAR(all_contracts[Date]) <= EndYear
)
)
fianlly, add the Measure to a Table or Visualization (Use the Filtered Contracts measure in a table, card, or chart.
The measure dynamically updates based on the selected start and end years.)
Hope this helps!
😁😁