<?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: Problems with IF when comparing a Column Value to a Measure in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problems-with-IF-when-comparing-a-Column-Value-to-a-Measure/m-p/2255142#M54415</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="343431" data-lia-user-login="ValtteriN" class="lia-mention lia-mention-user"&gt;ValtteriN&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the reply. I don't have a relationship between the tables. I did try the ALL but it didn't solve my problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, your suggestion of moving the measure into a calculated column did work. I moved it into the MaintenanceForecast table and that problem has now been fixed. Thank you so much for the suggestion.&lt;/P&gt;</description>
    <pubDate>Fri, 24 Dec 2021 10:41:46 GMT</pubDate>
    <dc:creator>Spike_Craib</dc:creator>
    <dc:date>2021-12-24T10:41:46Z</dc:date>
    <item>
      <title>Problems with IF when comparing a Column Value to a Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problems-with-IF-when-comparing-a-Column-Value-to-a-Measure/m-p/2254080#M54384</link>
      <description>&lt;P&gt;Hi - Any help is gratefully appreciated. I've been looking at this problem for a few hours now and am stumped.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The Position&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following measures set to a format of Short Date&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;EM&gt;&lt;SPAN&gt;FY End = &lt;/SPAN&gt;&lt;SPAN&gt;LASTDATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;CalendarLookup[Calendar_Date]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;EM&gt;&lt;SPAN&gt;FY Start = FIRSTDATE(CalendarLookup[Calendar_Date])&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN&gt;CalendarLookup &lt;/SPAN&gt;&lt;/EM&gt;&lt;SPAN&gt;is an XLSX doc table.&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I have a table called&amp;nbsp;&lt;EM&gt;MaintenanceForecast&lt;/EM&gt; (also an XLSX doc table) One of the fields in this table is called&amp;nbsp;&lt;EM&gt;End Date.&amp;nbsp;&lt;/EM&gt;This is set as a Date in Short Date format.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Inside Power BI Desktop I have added a New Column to&amp;nbsp;&lt;EM&gt;MaintenanceForecast&lt;/EM&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;EM&gt;This Year End = IF(MaintenanceForecast[End Date] &amp;gt; [FY End], [FY End], IF(MaintenanceForecast &amp;gt; [FY Start], MaintenanceForecast[End Date],DATE(1066,1,1)))&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;(N.B. - The 1066 date is just a placeholder for now)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;The Problem&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The IF state never matches the first condition, no matter the date.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I have one entry that has an&amp;nbsp;&lt;EM&gt;End Date&lt;/EM&gt; of 26/06/2022 and a&amp;nbsp;&lt;EM&gt;FY End&lt;/EM&gt; of 27/02/2022. Now I may be getting old but the first date is greater than the second date; but I never get the correct answer.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I've done some troubleshooting and if I add a new column to my MaintenanceForecast table and manually add a value for FY End date then it works fine.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The problem is only when comparing a date from a table column versus a date from a measure.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I've even tried converting the column and measure dates to integers and comparing them. Same problem.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Now I'm stumped. Any suggestions?&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 23 Dec 2021 17:47:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problems-with-IF-when-comparing-a-Column-Value-to-a-Measure/m-p/2254080#M54384</guid>
      <dc:creator>Spike_Craib</dc:creator>
      <dc:date>2021-12-23T17:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with IF when comparing a Column Value to a Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problems-with-IF-when-comparing-a-Column-Value-to-a-Measure/m-p/2254223#M54386</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;Do you happen to have a relationship between your calendar table and maintance forecast? If you reference measures in a calculated column they will be evaluated in the columns filter context. and thus they will return the date used in the realtionship. If you add ALL to your end and start measures your calculations should work. This picture might elaborate what I mean (here I used LASTDATE measure and placed it in a calculated column):&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN&gt;FY End =&amp;nbsp;CALCULATE(&lt;/SPAN&gt;&lt;SPAN&gt;LASTDATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;CalendarLookup[Calendar_Date]&lt;/SPAN&gt;&lt;SPAN&gt;),ALL(CalendarLookup[)) Should work.&lt;BR /&gt;&lt;BR /&gt;I hope this helps and if it does consider accepting this post as a solution and giving it a thumbs up!&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Dec 2021 19:40:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problems-with-IF-when-comparing-a-Column-Value-to-a-Measure/m-p/2254223#M54386</guid>
      <dc:creator>ValtteriN</dc:creator>
      <dc:date>2021-12-23T19:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with IF when comparing a Column Value to a Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problems-with-IF-when-comparing-a-Column-Value-to-a-Measure/m-p/2255142#M54415</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="343431" data-lia-user-login="ValtteriN" class="lia-mention lia-mention-user"&gt;ValtteriN&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the reply. I don't have a relationship between the tables. I did try the ALL but it didn't solve my problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, your suggestion of moving the measure into a calculated column did work. I moved it into the MaintenanceForecast table and that problem has now been fixed. Thank you so much for the suggestion.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Dec 2021 10:41:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problems-with-IF-when-comparing-a-Column-Value-to-a-Measure/m-p/2255142#M54415</guid>
      <dc:creator>Spike_Craib</dc:creator>
      <dc:date>2021-12-24T10:41:46Z</dc:date>
    </item>
  </channel>
</rss>

