Forum Discussion
Anonymous
3 years agoNot applicable
Nested If Statement
The DAX measure code below returns the engagement count and also term and year. I only want the selected term to show for example "Fall", but I get both Fall and Spring as shown below.
If I remove one If statement and run for either "Fall" or "Spring", I generate the correct ouput.
I am sure the issue is with the commas, but I am not sure how to make this an (If, Yes, No) statement.
I greatly appreeciate your assistance with t his formatting issue.
-----------------------------------------------------------------------------------------------------------------------------
VAR _program = Enrollment[ProgramSelection]
VAR _termyear = Enrollment[TermYearSelection]
VAR _intdate = (Int(Right(Enrollment[AYYearSelection],4)))
VAR _sterm = LEFT(SELECTEDVALUE(Enrollment[Start Term and Year]),2)
VAR _enddate = SWITCH(_intdate,
2024, TODAY(),
2023, TODAY(),
2022, EDATE(TODAY(), -12),
2021, EDATE(TODAY(), -24),
2020, EDATE(TODAY(), -36),
2019, EDATE(TODAY(), -48)
)
VAR _count1 = IF( _sterm = "Fa",
CALCULATE(COUNTROWS(Enrollment),
Enrollment[Program] = _program,
Enrollment[Start Term and Year] = _termyear,
Enrollment[Deposit Intent to Enroll] = "Yes",
Enrollment[TermName] = SELECTEDVALUE(FallFilter[Term])),
IF( _sterm = "Sp",
CALCULATE(COUNTROWS(Enrollment),
Enrollment[Program] = _program,
Enrollment[Start Term and Year] = _termyear,
Enrollment[Deposit Intent to Enroll] = "Yes",
Enrollment[TermName] = SELECTEDVALUE(SpringFilter[Term])))
)
RETURN
_count1
1 Reply
- Greg_DecklerCommunity Champion
Anonymous Try using SWITCH instead of nested IF statements.