misstoffeepenny
New Member
- Joined
- Jan 18, 2021
- Messages
- 19
- Office Version
- 365
- 2016
- 2011
- Platform
- Windows
Hi all,
I have a measure if statement to calculate the AAFR based on the different companies for YTD. When I set the filter to 'Maine Group' it calculates the correct value, when I select 'Smyth Steel' it calculates the correct value however if I don't filter the data I get a value approx. 10x the correct value. Can anyone help me debug my formula?
NB all my relationships are correct in my data model, it's just the math that isn't working. Also note these are the only 2 current companies in the company table.
formula:
IF(
MAX('Company'[Company]) = "Maine Group",
CALCULATE(
(COUNT('Ext Accident Log'[Injury Type]) / AVERAGE(EmployeeCount[Maine Employee Count]) * 100000),
DATESYTD('Calendar'[Date])
),
IF(
MAX('Company'[Company]) = "Smyth Steel",
CALCULATE(
(COUNT('Ext Accident Log'[Injury Type]) / AVERAGE(EmployeeCount[Smyth Steel Employee Count]) * 100000),
DATESYTD('Calendar'[Date])
),
CALCULATE(
(COUNT('Ext Accident Log'[Injury Type]) / AVERAGE(EmployeeCount[Total Employee Count]) * 100000),
DATESYTD('Calendar'[Date])
)
)
)
I have a measure if statement to calculate the AAFR based on the different companies for YTD. When I set the filter to 'Maine Group' it calculates the correct value, when I select 'Smyth Steel' it calculates the correct value however if I don't filter the data I get a value approx. 10x the correct value. Can anyone help me debug my formula?
NB all my relationships are correct in my data model, it's just the math that isn't working. Also note these are the only 2 current companies in the company table.
formula:
IF(
MAX('Company'[Company]) = "Maine Group",
CALCULATE(
(COUNT('Ext Accident Log'[Injury Type]) / AVERAGE(EmployeeCount[Maine Employee Count]) * 100000),
DATESYTD('Calendar'[Date])
),
IF(
MAX('Company'[Company]) = "Smyth Steel",
CALCULATE(
(COUNT('Ext Accident Log'[Injury Type]) / AVERAGE(EmployeeCount[Smyth Steel Employee Count]) * 100000),
DATESYTD('Calendar'[Date])
),
CALCULATE(
(COUNT('Ext Accident Log'[Injury Type]) / AVERAGE(EmployeeCount[Total Employee Count]) * 100000),
DATESYTD('Calendar'[Date])
)
)
)