Forum Discussion
Calculate Difference between 2 dates based on a Year slicer
Hi TBensen ,
For what I see, there's no need to use the Incident Table for this scenario.
I also assume that "MinValueRange" is the minimum year difference identified for any employee on that range, the same idea for the "MaxValueRange", and the "RangeIndex" is the total amount of employees that are in that range.
I created three tables: "Employees", "BinSelect" and "Calendar", and used three measures to achieve what you are looking for.
See the file: https://1drv.ms/u/s!ApEQfav9p1cQjivnqaCIb-Ly_9g_?e=DS5qQF
MEASURE 1:
MinValueRange =
MINX(FILTER(ADDCOLUMNS(Employees,
"Seniority_Range_FilteredYear",
MAX('Calendar'[Year])-YEAR(Employees[Hire_Date])
),
[Seniority_Range_FilteredYear]>=MAX(BinSelect[Min]) &&
[Seniority_Range_FilteredYear]<=MAX(BinSelect[Max])
),
[Seniority_Range_FilteredYear]
)
MEASURE 2:
MaxValueRange =
MAXX(FILTER(ADDCOLUMNS(Employees,
"Seniority_Range_FilteredYear",
MAX('Calendar'[Year])-YEAR(Employees[Hire_Date])
),
[Seniority_Range_FilteredYear]>=MAX(BinSelect[Min]) &&
[Seniority_Range_FilteredYear]<=MAX(BinSelect[Max])
),
[Seniority_Range_FilteredYear]
)
MEASURE 3:
RangeIndex =
COUNTROWS(FILTER(ADDCOLUMNS(Employees,
"Seniority_Range_FilteredYear",
MAX('Calendar'[Year])-YEAR(Employees[Hire_Date])
),
[Seniority_Range_FilteredYear]>=MAX(BinSelect[Min]) &&
[Seniority_Range_FilteredYear]<=MAX(BinSelect[Max])
)
)
Jesus.
Hello Jesus,
Thank you for your response. One of the reasons I included the Incident table is because there is a date (Year) slicer setup in the dashboard to allow the user to select the Year for the Date of Incident. When this year date is selected, there is a visualization that shows the counts of employees in their respective ranged bins based on the Year of the Date of Incident.
To further complicate this, I'm also taking the number of incidents for that year per population bin and dividing that by the number of people per population bin to get a rate.
Thanks,
Trevor