<?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: DAX IF() not working as expected. in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-IF-not-working-as-expected/m-p/1032617#M13629</link>
    <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&lt;/P&gt;&lt;P&gt;Yes, It is the same issue. Thank You.&lt;/P&gt;&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;When I add a second comma in the IF() after the logical_test, it seems to work.&lt;/P&gt;&lt;P&gt;Doing this:&amp;nbsp;&lt;SPAN&gt;var QuotingTime = IF(timeFromPending&amp;lt;0,&lt;/SPAN&gt;&lt;FONT color="#ff0000"&gt;,&lt;/FONT&gt;&lt;SPAN&gt; timeFromQuoting, timeFromPending) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Anonymous&lt;/a&gt;seems to think its some numer/regional setting, but we can't seem to figure out what exactly it is.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Fri, 17 Apr 2020 14:22:22 GMT</pubDate>
    <dc:creator>TBardien</dc:creator>
    <dc:date>2020-04-17T14:22:22Z</dc:date>
    <item>
      <title>DAX IF() not working as expected.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-IF-not-working-as-expected/m-p/1032147#M13558</link>
      <description>&lt;P&gt;I am new to Power BI. I am trying to use the &lt;EM&gt;&lt;SPAN class="hljs-built_in"&gt;IF&lt;/SPAN&gt;(&amp;lt;logical_test&amp;gt;,&amp;lt;value_if_true&amp;gt;[, &amp;lt;value_if_false&amp;gt;])&lt;/EM&gt; function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my code:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;var timeFromPending = DATEDIFF(RequestWorkflowHistory[Quote Pending Max], RequestWorkflowHistory[Quoted], MINUTE) / 60&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;var timeFromQuoting = DATEDIFF(RequestWorkflowHistory[Quoting], RequestWorkflowHistory[Quoted], MINUTE) / 60&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;var QuotingTime = IF(timeFromPending&amp;lt;0, timeFromQuoting, timeFromPending) &lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;return QuotingTime&lt;/STRONG&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I get a syntax error for "&lt;SPAN&gt;timeFromQuoting&lt;/SPAN&gt;", error is: "&lt;STRONG&gt;unexpected expression 'timeFromQuoting'&lt;/STRONG&gt;".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when I replace the variable for the&amp;nbsp;&lt;EM&gt;&amp;lt;value_if_true&amp;gt;&lt;/EM&gt; parameter, with a hardcoded value, the error seems to disappear.&lt;/P&gt;&lt;P&gt;example if I do something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;var timeFromPending = DATEDIFF(RequestWorkflowHistory[Quote Pending Max], RequestWorkflowHistory[Quoted], MINUTE) / 60&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;var timeFromQuoting = DATEDIFF(RequestWorkflowHistory[Quoting], RequestWorkflowHistory[Quoted], MINUTE) / 60&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;var QuotingTime = IF(timeFromPending&amp;lt;0,0, timeFromPending) &lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;return QuotingTime&lt;/STRONG&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone tell me why this would be happenning?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS. I also think this related to my previous post: &lt;A title="DAX-IF-no-longer-working" href="https://community.powerbi.com/t5/DAX-Commands-and-Tips/DAX-IF-no-longer-working/m-p/1032116#M13554" target="_blank" rel="noopener"&gt;DAX-IF-no-longer-working&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 10:13:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-IF-not-working-as-expected/m-p/1032147#M13558</guid>
      <dc:creator>TBardien</dc:creator>
      <dc:date>2020-04-17T10:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: DAX IF() not working as expected.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-IF-not-working-as-expected/m-p/1032318#M13581</link>
      <description>So can you post some sample data so that we can try to replicate this easily? &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Apr 2020 12:04:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-IF-not-working-as-expected/m-p/1032318#M13581</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2020-04-17T12:04:47Z</dc:date>
    </item>
    <item>
      <title>Re: DAX IF() not working as expected.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-IF-not-working-as-expected/m-p/1032368#M13594</link>
      <description>&lt;P&gt;&lt;FONT&gt;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;It does return if I remove the IF(). However, im going to need to be able to use the IF().&lt;BR /&gt;I uninstalled PowerBI and reinstalled, it still did not work.&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;I also downloaded the PowerBI sample "Sales &amp;amp; Returns Sample v201912Sales &amp;amp; Returns Sample v201912" and I got the error there too for the code:&lt;BR /&gt;&lt;STRONG&gt;Product Returns Top 3 = IF([ProductR Top N]&amp;lt;4,[Returns],0)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;The syntax for '[Returns]' is incorrect. (DAX(IF([ProductR Top N]&amp;lt;4.[Returns],0))).&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This makes me think there is a bigger issue.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 12:30:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-IF-not-working-as-expected/m-p/1032368#M13594</guid>
      <dc:creator>TBardien</dc:creator>
      <dc:date>2020-04-17T12:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: DAX IF() not working as expected.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-IF-not-working-as-expected/m-p/1032446#M13608</link>
      <description>There is something not correct in your first comma. The error is showing that it thinks it is a period. Also, you can tell that there is a difference in your two commas in that IF statement. Did you copy and paste this code from somewhere? Thinking that first comma is some extended character set. Try replacing that comma with a normal comma.</description>
      <pubDate>Fri, 17 Apr 2020 13:11:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-IF-not-working-as-expected/m-p/1032446#M13608</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2020-04-17T13:11:24Z</dc:date>
    </item>
    <item>
      <title>Re: DAX IF() not working as expected.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-IF-not-working-as-expected/m-p/1032503#M13618</link>
      <description>&lt;P&gt;Yes i think it is the same solution from your other post.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the first case you got the same problem that Power BI&amp;nbsp; thinks "0,timeFromQuoting" is one expression. In the second example you have &lt;STRONG&gt;timeFromPending&amp;lt;0,0&lt;/STRONG&gt;&amp;nbsp; (international &lt;STRONG&gt;timeFromPending&amp;lt;0.0&lt;/STRONG&gt;) and and only the true case &lt;STRONG&gt;timeFromPending&lt;/STRONG&gt; (because the real true case 0 is in the inequality statement).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So again try the second "," should work&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;var timeFromPending = DATEDIFF(RequestWorkflowHistory[Quote Pending Max], RequestWorkflowHistory[Quoted], MINUTE) / 60&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;var timeFromQuoting = DATEDIFF(RequestWorkflowHistory[Quoting], RequestWorkflowHistory[Quoted], MINUTE) / 60&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;var QuotingTime = IF(timeFromPending&amp;lt;0,&lt;FONT color="#FF0000"&gt;,&lt;/FONT&gt; timeFromQuoting, timeFromPending) &lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;return QuotingTime&lt;/STRONG&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Bruening&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 13:47:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-IF-not-working-as-expected/m-p/1032503#M13618</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-17T13:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: DAX IF() not working as expected.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-IF-not-working-as-expected/m-p/1032617#M13629</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Yes, It is the same issue. Thank You.&lt;/P&gt;&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;When I add a second comma in the IF() after the logical_test, it seems to work.&lt;/P&gt;&lt;P&gt;Doing this:&amp;nbsp;&lt;SPAN&gt;var QuotingTime = IF(timeFromPending&amp;lt;0,&lt;/SPAN&gt;&lt;FONT color="#ff0000"&gt;,&lt;/FONT&gt;&lt;SPAN&gt; timeFromQuoting, timeFromPending) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Anonymous&lt;/a&gt;seems to think its some numer/regional setting, but we can't seem to figure out what exactly it is.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 17 Apr 2020 14:22:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-IF-not-working-as-expected/m-p/1032617#M13629</guid>
      <dc:creator>TBardien</dc:creator>
      <dc:date>2020-04-17T14:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: DAX IF() not working as expected.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-IF-not-working-as-expected/m-p/1032679#M13632</link>
      <description>When I wrote my first book, I had some of these issues when formulas were checked with international settings and I found that putting spaces after my commas in my formulas tended to fix the issues. Basically what was going on from what I could tell is that DAX ends up thinking it is a decimal point because everything is numeric. but when you put a space in, DAX wises up and realizes it is not just all one decimal number.</description>
      <pubDate>Fri, 17 Apr 2020 14:51:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-IF-not-working-as-expected/m-p/1032679#M13632</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2020-04-17T14:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: DAX IF() not working as expected.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-IF-not-working-as-expected/m-p/1032682#M13633</link>
      <description>&lt;P&gt;Regional settings are found in two places. File | Options and settings | Options and then there are two places for Regional Settings, default and CURRENT FILE.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 14:53:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-IF-not-working-as-expected/m-p/1032682#M13633</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2020-04-17T14:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: DAX IF() not working as expected.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-IF-not-working-as-expected/m-p/1037153#M13829</link>
      <description>&lt;P&gt;Spaces BEFORE the comma seems to do the trick.&lt;/P&gt;&lt;P&gt;So instead of:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;IF(_time &amp;lt; 0, BLANK(), _time)&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;you would make it:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;IF(_time &amp;lt; 0 , BLANK(), _time)&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 20 Apr 2020 16:26:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-IF-not-working-as-expected/m-p/1037153#M13829</guid>
      <dc:creator>TBardien</dc:creator>
      <dc:date>2020-04-20T16:26:57Z</dc:date>
    </item>
  </channel>
</rss>

