<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Need help with multi IF statements in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-multi-IF-statements/m-p/4725593#M181008</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="296339" data-lia-user-login="JustinDoh1" class="lia-mention lia-mention-user"&gt;JustinDoh1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;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 &amp;lt;&amp;gt; _LongStayScore, MAX ( _Diff1, BLANK () ),   --blank is bigger than negative
        tblSLTC_FSPI[ShortStayLogic] = "Not Reported", MAX ( _Diff2, BLANK () )   --blank is bigger than negative
    )
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="529075" data-lia-user-login="burakkaragoz" class="lia-mention lia-mention-user"&gt;burakkaragoz&lt;/a&gt;&amp;nbsp;Let us please not rely too much on AI and validate the solutions we provide.&amp;nbsp; ShortStayScore and LongStayScore are both numbers so comparing them with text in variable BothScoresReported will return an error.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 09 Jun 2025 22:47:17 GMT</pubDate>
    <dc:creator>danextian</dc:creator>
    <dc:date>2025-06-09T22:47:17Z</dc:date>
    <item>
      <title>Need help with multi IF statements</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-multi-IF-statements/m-p/4723630#M180934</link>
      <description>&lt;P&gt;I have attached &lt;A href="https://drive.google.com/file/d/14_Pa9Ldrdv7nTh3NnwSv5enpP1ABOBhl/view?usp=sharing" target="_self"&gt;my PBIX file here&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;I am trying to create a column ("&lt;STRONG&gt;Difference to 5-Star condition3&lt;/STRONG&gt;") with outputs based on the logic below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If ShortStayScore and LongStayScore are different,&lt;/P&gt;&lt;P&gt;Subtract its total (ShortStayScore + LongStayScore) from 1456 --&amp;gt;&amp;nbsp; (meaning:&amp;nbsp; 1456 – ((ShortStayScore + LongStayScore)),&lt;/P&gt;&lt;P&gt;If the value becomes negative, put blank.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If ShortStayScore and LongStayScore are same (meaning ShortStayScore = ‘Not Reported’),&lt;/P&gt;&lt;P&gt;Subtract LongStayScore from 736 --&amp;gt;&amp;nbsp; (meaning: 736 – (LongStayScore)),&lt;/P&gt;&lt;P&gt;If the value becomes negative, put blank.&lt;/P&gt;&lt;P&gt;------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is examples:&lt;/P&gt;&lt;P&gt;I only illustrated 6 examples here:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jun 2025 22:01:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-multi-IF-statements/m-p/4723630#M180934</guid>
      <dc:creator>JustinDoh1</dc:creator>
      <dc:date>2025-06-06T22:01:32Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with multi IF statements</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-multi-IF-statements/m-p/4723631#M180935</link>
      <description>&lt;H3&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="296339" data-lia-user-login="JustinDoh1" class="lia-mention lia-mention-user"&gt;JustinDoh1&lt;/a&gt;&amp;nbsp;,&lt;/H3&gt;&lt;DIV class=""&gt;&lt;P&gt;Great explanation and thanks for providing clear logic and examples! You can achieve this in Power BI using a DAX calculated column with nested IF statements to handle both scenarios.&lt;/P&gt;&lt;P&gt;Here’s the DAX you can use:&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;PRE&gt;Difference to 5-Star condition3 = 
VAR ShortStay = [ShortStayScore]
VAR LongStay = [LongStayScore]
VAR BothScoresReported = 
    AND(
        ShortStay &amp;lt;&amp;gt; "Not Reported",
        LongStay &amp;lt;&amp;gt; "Not Reported"
    )
VAR BothScoresSame = ShortStay = LongStay

// If both scores are reported and different, use the first logic
RETURN
IF(
    BothScoresReported &amp;amp;&amp;amp; NOT BothScoresSame,
    VAR Diff = 1456 - (ShortStay + LongStay)
    RETURN IF(Diff &amp;lt; 0, BLANK(), Diff),
    // If both scores are the same (or ShortStayScore = 'Not Reported'), use the second logic
    IF(
        LongStay &amp;lt;&amp;gt; "Not Reported",
        VAR Diff2 = 736 - LongStay
        RETURN IF(Diff2 &amp;lt; 0, BLANK(), Diff2),
        BLANK()
    )
)&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt;A few extra tips:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Make sure that “Not Reported” is treated as a text value (not a number). If your data is numeric with blanks for “Not Reported”, use&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;ISBLANK([ShortStayScore])&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;or&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;ISBLANK([LongStayScore])&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;instead.&lt;/LI&gt;&lt;LI&gt;Adjust the column names as needed to match your data model exactly.&lt;/LI&gt;&lt;LI&gt;If you want to display the word "BLANK" instead of a blank value, you can replace&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;BLANK()&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;"BLANK"&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;in the IF statements.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Let me know if you need help adjusting this logic for your specific dataset, or if you want to handle more scenarios!&lt;/P&gt;&lt;P&gt;Happy to help further if needed!&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;&lt;SPAN&gt;translation and formatting supported by AI&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 01 Jul 2025 09:08:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-multi-IF-statements/m-p/4723631#M180935</guid>
      <dc:creator>burakkaragoz</dc:creator>
      <dc:date>2025-07-01T09:08:49Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with multi IF statements</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-multi-IF-statements/m-p/4724709#M180967</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="529075" data-lia-user-login="burakkaragoz" class="lia-mention lia-mention-user"&gt;burakkaragoz&lt;/a&gt;&amp;nbsp;Thank you so much for your help.&lt;/P&gt;&lt;P&gt;I tried creating a column, and got this bottom message:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jun 2025 01:09:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-multi-IF-statements/m-p/4724709#M180967</guid>
      <dc:creator>JustinDoh1</dc:creator>
      <dc:date>2025-06-09T01:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with multi IF statements</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-multi-IF-statements/m-p/4724838#M180974</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="296339" data-lia-user-login="JustinDoh1" class="lia-mention lia-mention-user"&gt;JustinDoh1&lt;/a&gt;,&lt;BR /&gt;Thank you for reaching out to the Microsoft fabric community forum. &lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;I have reproduced your scenario in Power BI Desktop and successfully achieved the expected output as per your requirements.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;For your reference, I’m attaching the &lt;STRONG&gt;.pbix&lt;/STRONG&gt; file containing the solution. You can download it and review the setup to apply it to your report.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;If this information is helpful, please &lt;STRONG&gt;“Accept as solution”&lt;/STRONG&gt; and give a &lt;STRONG&gt;"kudos"&lt;/STRONG&gt; to assist other community members in resolving similar issues more efficiently.&lt;BR /&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jun 2025 11:49:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-multi-IF-statements/m-p/4724838#M180974</guid>
      <dc:creator>v-ssriganesh</dc:creator>
      <dc:date>2025-06-09T11:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with multi IF statements</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-multi-IF-statements/m-p/4725593#M181008</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="296339" data-lia-user-login="JustinDoh1" class="lia-mention lia-mention-user"&gt;JustinDoh1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;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 &amp;lt;&amp;gt; _LongStayScore, MAX ( _Diff1, BLANK () ),   --blank is bigger than negative
        tblSLTC_FSPI[ShortStayLogic] = "Not Reported", MAX ( _Diff2, BLANK () )   --blank is bigger than negative
    )
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="529075" data-lia-user-login="burakkaragoz" class="lia-mention lia-mention-user"&gt;burakkaragoz&lt;/a&gt;&amp;nbsp;Let us please not rely too much on AI and validate the solutions we provide.&amp;nbsp; ShortStayScore and LongStayScore are both numbers so comparing them with text in variable BothScoresReported will return an error.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jun 2025 22:47:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-multi-IF-statements/m-p/4725593#M181008</guid>
      <dc:creator>danextian</dc:creator>
      <dc:date>2025-06-09T22:47:17Z</dc:date>
    </item>
  </channel>
</rss>

