<?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: IF, (AND/OR), ISFILTERED Measure Combination not working as planned when interacting with Dates in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-AND-OR-ISFILTERED-Measure-Combination-not-working-as-planned/m-p/3086261#M107892</link>
    <description>&lt;P&gt;Yes, That works, fixed it on my original file, what was happening was, the firstD part was not selecting the right date, and the numbers were being thrown off, I thought maybe the ISFILTERED() function might fix it.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR firstD =
    CALCULATE (
        MIN ( 'Date'[Date] ),
        ALLSELECTED ( 'Date'[Date] )
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 18 Feb 2023 20:16:09 GMT</pubDate>
    <dc:creator>bipowerbix</dc:creator>
    <dc:date>2023-02-18T20:16:09Z</dc:date>
    <item>
      <title>IF, (AND/OR), ISFILTERED Measure Combination not working as planned when interacting with Dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-AND-OR-ISFILTERED-Measure-Combination-not-working-as-planned/m-p/3085889#M107860</link>
      <description>&lt;P&gt;Below is the sample data we will use for this experiment, First Column are dates, the second one shows Categories and the last one shows values.&lt;/P&gt;&lt;P&gt;Date&amp;nbsp; &amp;nbsp;Categories&amp;nbsp; &amp;nbsp;Value&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;10/5/2022&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;25&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;11/2/2022&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;45&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12/9/2022&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;35&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12/15/2022&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12/30/2022&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;40&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/5/2023&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;60&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/28/2023&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/1/2023&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;80&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/5/2023&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/9/2023&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;70&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data has two slicers Date and Categories. Below is the DAX statement I have used&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Formula = 
var new = sum(Test[Value]) * 10
var startyear = DATE(YEAR(TODAY()),1,1) 
var firstD = CALCULATE( MIN( Test[Date]), ALLSELECTED(Test[Date]) )
return if( ISFILTERED(Test[Categories]) &amp;amp;&amp;amp; firstD &amp;gt;= startyear, new, 0 )&lt;/LI-CODE&gt;&lt;P&gt;I am writing a DAX Statement to multiply column 3(values)&lt;STRONG&gt;&amp;nbsp;by 10&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;only if the date range is in the current year&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;2023.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;StartYear&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;gives the start of the current year,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;firstD&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;gives the lowest date from the date slicer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Now when I filter dates to 2023, the total value should be 2300 but it shows as 0, Image below&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, the DAX works when I select A or B, Image below&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have also tried removing ISFILTERED function from the measure even though it is mandatory for this measure to interact with the slicer, Now the value shows 650 when it is expected to be 0 because the year is 2022 and not 2023&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Expected Function:&lt;/STRONG&gt; I want the Measure to interact with both the date and category slicer and show &lt;STRONG&gt;(value) * 10&lt;/STRONG&gt; if the date slicer is greater than &lt;STRONG&gt;1/1/2023&lt;/STRONG&gt; and &lt;STRONG&gt;0&lt;/STRONG&gt; when in date slicer starts from any date of 2022. The result should work if the category slicer is selected or not selected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Feb 2023 03:34:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-AND-OR-ISFILTERED-Measure-Combination-not-working-as-planned/m-p/3085889#M107860</guid>
      <dc:creator>bipowerbix</dc:creator>
      <dc:date>2023-02-18T03:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: IF, (AND/OR), ISFILTERED Measure Combination not working as planned when interacting with Dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-AND-OR-ISFILTERED-Measure-Combination-not-working-as-planned/m-p/3085947#M107867</link>
      <description>&lt;P&gt;Hi there&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="516939" data-lia-user-login="bipowerbix" class="lia-mention lia-mention-user"&gt;bipowerbix&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;It is generally recommended to create a Date dimension table, when applying filters or any logic relating to date columns. The Date column from the Date table should then be used on slicers and any logical tests relating to the Date filter context. In this example, using a separate Date table ensures the date selection on the slicer corresponds exactly to the filtered Date values. Using Test[Date] means that the filtered values are only those actually present in the Test table.&lt;/LI&gt;
&lt;LI&gt;As far as I can see, the ISFILTERED condition is not required (but I could be missing something - let me know if I am). The Categories slicer will interact with any other visuals on the page as long as interactions are enabled (as they are by default).The expression&lt;STRONG&gt; ISFILTERED ( Test[Categories] ) &lt;/STRONG&gt;will return TRUE only if a filter has been placed on the Categories column. This will be true if at least one selection is made on the Categories slicer, but not if no selections have been made (as in the slicer's default state).&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;So I think you can get the correct behaviour by:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Adding a 'Date' table and creating a 1:many relationship between 'Date'[Date] and Test[Date].&lt;BR /&gt;'Date' should contain a contiguous series of dates covering at least the range of dates in Test[Date], and should be marked as a date table (&lt;A href="https://learn.microsoft.com/en-us/power-bi/transform-model/desktop-date-tables#set-your-own-date-table" target="_blank" rel="noopener"&gt;see here).&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Use 'Date'[Date] on the slicer.&lt;/LI&gt;
&lt;LI&gt;Rewrite the &lt;STRONG&gt;Formula&lt;/STRONG&gt; measure&amp;nbsp;as below, referencing 'Date'[Date] and without the ISFILTERED test:&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Formula = 
VAR new =
    SUM ( Test[Value] ) * 10
VAR startyear =
    DATE ( YEAR ( TODAY () ), 1, 1 )
VAR firstD =
    CALCULATE (
        MIN ( 'Date'[Date] ),
        ALLSELECTED ( 'Date'[Date] )
    )
RETURN
    IF (
        firstD &amp;gt;= startyear,
        new,
        0
        -- Returning 0 is fine for use in a card or other visual displaying a single value,
        -- but recommended in visuals that group by one or more columns.
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sample PBIX is attached.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does this work for you?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Sat, 18 Feb 2023 05:53:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-AND-OR-ISFILTERED-Measure-Combination-not-working-as-planned/m-p/3085947#M107867</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2023-02-18T05:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: IF, (AND/OR), ISFILTERED Measure Combination not working as planned when interacting with Dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-AND-OR-ISFILTERED-Measure-Combination-not-working-as-planned/m-p/3086261#M107892</link>
      <description>&lt;P&gt;Yes, That works, fixed it on my original file, what was happening was, the firstD part was not selecting the right date, and the numbers were being thrown off, I thought maybe the ISFILTERED() function might fix it.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR firstD =
    CALCULATE (
        MIN ( 'Date'[Date] ),
        ALLSELECTED ( 'Date'[Date] )
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Feb 2023 20:16:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-AND-OR-ISFILTERED-Measure-Combination-not-working-as-planned/m-p/3086261#M107892</guid>
      <dc:creator>bipowerbix</dc:creator>
      <dc:date>2023-02-18T20:16:09Z</dc:date>
    </item>
  </channel>
</rss>

