Normally the below code works when i am not working with Filed Parameters. But when i am using it with field parameter, its returning error
MdxScript(Model) (431, 21) Calculation error in measure •_measurei[Max bar dept.org Resignation]: Column [Dept.Org Lvl] is part of composite key, but not all columns of the composite key are included in the expression or its dependent expression.
Overall Max/Min linechart Overall Attrition =
VAR Resignation = [# of resignation]
VAR SelectedField = SELECTEDVALUE('Age-tenure'[Age-tenure])
VAR MaxResignation =
SWITCH(
SelectedField,
"Age Banding", MAXX(ALLSELECTED(fact_employee[Age Band]), [Overall Attrition Rate]),
"Tenure Banding", MAXX(ALLSELECTED(fact_resigned[Tenure Banding]), [Overall Attrition Rate])
)
VAR MinResignation =
SWITCH(
SelectedField,
"Age Banding", MINX(ALLSELECTED(fact_employee[Age Band]), [Overall Attrition Rate]),
"Tenure Banding", MINX(ALLSELECTED(fact_resigned[Tenure Banding]), [Overall Attrition Rate])
)
-- Determine the color based on Max and Min
VAR Result =
SWITCH(
TRUE(),
Resignation = MaxResignation, "RED",
Resignation = MinResignation, "Green",
"#751d84"
)
RETURN
Result