Forum Discussion
JustinDoh1
Post Prodigy
1 year agoNeed help with multi IF statements
I have attached my PBIX file here. I am trying to create a column ("Difference to 5-Star condition3") with outputs based on the logic below: -----------------------------------------------------...
- 1 year ago
Hi JustinDoh1
Please try this:
Difference to 5-Star condition3 = VAR _ShortStayScore = tblSLTC_FSPI[ShortStayScore] VAR _LongStayScore = tblSLTC_FSPI[LongStayScore] VAR _ShortLongScore = _ShortStayScore + _LongStayScore VAR _Diff1 = 1456 - _ShortLongScore VAR _Diff2 = 736 - _LongStayScore RETURN SWITCH ( TRUE (), _ShortStayScore <> _LongStayScore, MAX ( _Diff1, BLANK () ), --blank is bigger than negative tblSLTC_FSPI[ShortStayLogic] = "Not Reported", MAX ( _Diff2, BLANK () ) --blank is bigger than negative )burakkaragoz Let us please not rely too much on AI and validate the solutions we provide. ShortStayScore and LongStayScore are both numbers so comparing them with text in variable BothScoresReported will return an error.
JustinDoh1
Post Prodigy
1 year agoburakkaragoz Thank you so much for your help.
I tried creating a column, and got this bottom message:
danextian
Super User
1 year agoHi JustinDoh1
Please try this:
Difference to 5-Star condition3 =
VAR _ShortStayScore = tblSLTC_FSPI[ShortStayScore]
VAR _LongStayScore = tblSLTC_FSPI[LongStayScore]
VAR _ShortLongScore = _ShortStayScore + _LongStayScore
VAR _Diff1 = 1456 - _ShortLongScore
VAR _Diff2 = 736 - _LongStayScore
RETURN
SWITCH (
TRUE (),
_ShortStayScore <> _LongStayScore, MAX ( _Diff1, BLANK () ), --blank is bigger than negative
tblSLTC_FSPI[ShortStayLogic] = "Not Reported", MAX ( _Diff2, BLANK () ) --blank is bigger than negative
)
burakkaragoz Let us please not rely too much on AI and validate the solutions we provide. ShortStayScore and LongStayScore are both numbers so comparing them with text in variable BothScoresReported will return an error.