<?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 Query in Dax in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/If-Query-in-Dax/m-p/4299503#M170734</link>
    <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;i want the value fron FRiday at monday, because at saturday&amp;nbsp; and sunday ihave no values.&lt;BR /&gt;From Time to time the Storage is working at Saturaday an Sunday.&lt;BR /&gt;In this case i need the value from the deay before.....&lt;BR /&gt;&lt;BR /&gt;So I always need the value of the last day in which values are available.&lt;BR /&gt;If the weekend was not worked, I need the value from Friday or the last active day before today.&lt;BR /&gt;I always need the value of the last active day before today.....&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 25 Nov 2024 08:29:59 GMT</pubDate>
    <dc:creator>Sammy1965</dc:creator>
    <dc:date>2024-11-25T08:29:59Z</dc:date>
    <item>
      <title>If Query in Dax</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/If-Query-in-Dax/m-p/4296952#M170589</link>
      <description>&lt;P&gt;I have created a live dashboard where I query the posting date of an order in a field using the Posting Date field.&lt;/P&gt;&lt;P&gt;For today&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Warenausgänge heute = CALCULATE(
COUNT('Archiv_Gebuchte_Warenausgänge'[No_]),
'Archiv_Gebuchte_Warenausgänge'[Posting Date]=TODAY()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;For yesterday&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Warenausgänge gestern1 = CALCULATE(
COUNT('Archiv_Gebuchte_Warenausgänge'[No_]),
'Archiv_Gebuchte_Warenausgänge'[Posting Date]=PREVOUSDAY()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The problem is that when I look at my dashboard on Monday, the field only shows ‘empty’ because no work was done on Sunday or Saturday.&lt;/P&gt;&lt;P&gt;How do I design the DAX query so that it checks the previous day and 2 previous days to see if they are empty. Because sometimes there is also work on Saturday.&lt;/P&gt;&lt;P&gt;How do I query the above-mentioned measures to check whether the [Posting Date] field is filled on the previous day and 2 days before?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If the previous day does not exist, then take 2 days before, if 2 days before nothing exists, then take 3 days before&lt;/P&gt;&lt;P&gt;Translated with DeepL.com (free version)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2024 09:29:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/If-Query-in-Dax/m-p/4296952#M170589</guid>
      <dc:creator>Sammy1965</dc:creator>
      <dc:date>2024-11-22T09:29:54Z</dc:date>
    </item>
    <item>
      <title>Re: If Query in Dax</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/If-Query-in-Dax/m-p/4297025#M170595</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="859531" data-lia-user-login="Sammy1965" class="lia-mention lia-mention-user"&gt;Sammy1965&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To design a DAX query that checks the &lt;STRONG&gt;previous day&lt;/STRONG&gt;, &lt;STRONG&gt;two days before&lt;/STRONG&gt;, and &lt;STRONG&gt;three days before&lt;/STRONG&gt; in case the previous day has no data, you can use a combination of &lt;STRONG&gt;IF&lt;/STRONG&gt;, &lt;STRONG&gt;OR&lt;/STRONG&gt;, and &lt;STRONG&gt;CALCULATE&lt;/STRONG&gt; functions along with &lt;STRONG&gt;DATEADD&lt;/STRONG&gt; to evaluate the dates sequentially.&lt;/P&gt;&lt;H3&gt;Approach:&lt;/H3&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;First, check the previous day (Yesterday)&lt;/STRONG&gt;.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;If no data exists&lt;/STRONG&gt;, check two days before (two days ago).&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;If two days before has no data&lt;/STRONG&gt;, check three days before (three days ago).&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Here’s a possible solution using DAX:&lt;/P&gt;&lt;H3&gt;Measure for Orders (Work Done) on Previous Days:&lt;/H3&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Warenausgänge letze3Tage = 
VAR Yesterday = CALCULATE(COUNT('Archiv_Gebuchte_Warenausgänge'[No_]), 'Archiv_Gebuchte_Warenausgänge'[Posting Date] = PREVIOUSDAY(TODAY()))
VAR TwoDaysAgo = CALCULATE(COUNT('Archiv_Gebuchte_Warenausgänge'[No_]), 'Archiv_Gebuchte_Warenausgänge'[Posting Date] = DATEADD(TODAY(), -2, DAY))
VAR ThreeDaysAgo = CALCULATE(COUNT('Archiv_Gebuchte_Warenausgänge'[No_]), 'Archiv_Gebuchte_Warenausgänge'[Posting Date] = DATEADD(TODAY(), -3, DAY))

RETURN 
    IF(Yesterday &amp;gt; 0, Yesterday, 
        IF(TwoDaysAgo &amp;gt; 0, TwoDaysAgo, 
            IF(ThreeDaysAgo &amp;gt; 0, ThreeDaysAgo, 0)))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If your week starts on Monday and you want the measure to handle the weekend scenario properly (like checking Saturday or Friday if Sunday has no data), you might need to adjust the logic slightly based on the exact requirement, but this approach should work to look backward through the most recent dates with data.&lt;/P&gt;&lt;H3&gt;Summary:&lt;/H3&gt;&lt;UL&gt;&lt;LI&gt;The measure checks &lt;STRONG&gt;yesterday&lt;/STRONG&gt; first.&lt;/LI&gt;&lt;LI&gt;If no data is found for yesterday, it checks &lt;STRONG&gt;two days ago&lt;/STRONG&gt;, then &lt;STRONG&gt;three days ago&lt;/STRONG&gt;.&lt;/LI&gt;&lt;LI&gt;Returns 0 if no data is found for any of the days.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Did I answer your question? Mark my post as a solution, this will help others!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If my response(s) assisted you in any way, don't forget to drop me a "&lt;STRONG&gt;Kudos&lt;/STRONG&gt;" &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;BR /&gt;Poojara&lt;BR /&gt;Data Analyst | MSBI Developer | Power BI Consultant&lt;BR /&gt;&lt;STRONG&gt;Please Subscribe my YouTube for Beginners/Advance Concepts:&lt;/STRONG&gt;&amp;nbsp;&lt;A href="https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS" target="_self"&gt;https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2024 10:27:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/If-Query-in-Dax/m-p/4297025#M170595</guid>
      <dc:creator>Poojara_D12</dc:creator>
      <dc:date>2024-11-22T10:27:19Z</dc:date>
    </item>
    <item>
      <title>Re: If Query in Dax</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/If-Query-in-Dax/m-p/4299290#M170726</link>
      <description>&lt;P&gt;Hello Poojara_D12,&lt;/P&gt;&lt;P&gt;thank you very much for your quick reply. And thank you very much for your help.&lt;BR /&gt;DAX is still absolutely new to me and I have only been working with Power BI for a few weeks... (I love it)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;But I have an error message when i try to create the measure&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;img /&gt;&lt;BR /&gt;A function of type ‘PREVIOUSDAY’ was used in a true/false expression that serves as a table filter expression. This is not permitted.&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;The original message in German is:&lt;BR /&gt;&lt;EM&gt;Eine Funktion vom Typ 'PREVIOUSDAY' wurde in einem True/False-Ausdruck verwendet, der als Tabellenfilterausdruck dient. Dies ist nicht zulässig.&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2024 07:03:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/If-Query-in-Dax/m-p/4299290#M170726</guid>
      <dc:creator>Sammy1965</dc:creator>
      <dc:date>2024-11-25T07:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: If Query in Dax</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/If-Query-in-Dax/m-p/4299357#M170729</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="859531" data-lia-user-login="Sammy1965" class="lia-mention lia-mention-user"&gt;Sammy1965&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Base on your description, it seems like you want to the count of No_ which the date is before today. I created a sample pbix file(see &lt;EM&gt;&lt;STRONG&gt;the attachment&lt;/STRONG&gt;&lt;/EM&gt;), please check if that is what you want.&amp;nbsp; You can update the formla of measure&lt;/P&gt;
&lt;P&gt;[&lt;SPAN&gt;Warenausgänge gestern1&lt;/SPAN&gt;&lt;SPAN&gt;] as below:&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Warenausgänge gestern1 = 
VAR _predate =
    CALCULATE (
        MAX ( 'Archiv_Gebuchte_Warenausgänge'[Posting Date] ),
        FILTER (
            ALLSELECTED ( 'Archiv_Gebuchte_Warenausgänge' ),
            'Archiv_Gebuchte_Warenausgänge'[Posting Date] &amp;lt; TODAY ()
        )
    )
RETURN
    CALCULATE (
        COUNT ( 'Archiv_Gebuchte_Warenausgänge'[No_] ),
        FILTER (
            ALLSELECTED ( 'Archiv_Gebuchte_Warenausgänge' ),
            'Archiv_Gebuchte_Warenausgänge'[Posting Date] = _predate
        )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2024 07:34:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/If-Query-in-Dax/m-p/4299357#M170729</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-25T07:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: If Query in Dax</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/If-Query-in-Dax/m-p/4299503#M170734</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;i want the value fron FRiday at monday, because at saturday&amp;nbsp; and sunday ihave no values.&lt;BR /&gt;From Time to time the Storage is working at Saturaday an Sunday.&lt;BR /&gt;In this case i need the value from the deay before.....&lt;BR /&gt;&lt;BR /&gt;So I always need the value of the last day in which values are available.&lt;BR /&gt;If the weekend was not worked, I need the value from Friday or the last active day before today.&lt;BR /&gt;I always need the value of the last active day before today.....&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2024 08:29:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/If-Query-in-Dax/m-p/4299503#M170734</guid>
      <dc:creator>Sammy1965</dc:creator>
      <dc:date>2024-11-25T08:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: If Query in Dax</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/If-Query-in-Dax/m-p/4299857#M170747</link>
      <description>&lt;P&gt;You could create a measure like&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Prev Day =
VAR ValidDates =
    CALCULATETABLE (
        DISTINCT ( 'Archiv_Gebuchte_Warenausgänge'[Posting Date] ),
        'Archiv_Gebuchte_Warenausgänge'[Posting Date] &amp;lt; TODAY (),
        REMOVEFILTERS ( 'Date' )
    )
VAR PrevDay =
    INDEX (
        1,
        ValidDates,
        ORDERBY ( 'Archiv_Gebuchte_Warenausgänge'[Posting Date], DESC )
    )
RETURN
    PrevDay
&lt;/LI-CODE&gt;
&lt;P&gt;and a similar measure for the 2nd previous day by changing the 1 to 2.&lt;/P&gt;
&lt;P&gt;Once you have the measures you should be able to use them as filters in any calculations or visuals you need.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2024 12:02:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/If-Query-in-Dax/m-p/4299857#M170747</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2024-11-25T12:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: If Query in Dax</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/If-Query-in-Dax/m-p/4300776#M170783</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="859531" data-lia-user-login="Sammy1965" class="lia-mention lia-mention-user"&gt;Sammy1965&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The formula I provided in my previous post is designed to first identify the maximum date before today where the value is not blank, and then retrieve the value for that date. Could you please let me know if this solution is not working in your fact table? If possible, kindly share some sample data (&lt;EM&gt;&lt;STRONG&gt;excluding any sensitive information&lt;/STRONG&gt;&lt;/EM&gt;) along with the expected result based on the provided sample data.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;It would be helpful to find out the solution. You can refer the following link to share the required info:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FCommunity-Blog%2FHow-to-provide-sample-data-in-the-Power-BI-Forum%2Fba-p%2F963216&amp;amp;data=05%7C01%7CClaire.Dong%40microsoft.com%7Cada9149bd91546a8432508dacd31ef9b%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638047911607737134%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=EJlYfclgtrjgAEYj9Uo1AauqxaQm3hlQsjJMo4zCY1M%3D&amp;amp;reserved=0" target="_blank" rel="nofollow noopener noreferrer"&gt;How to provide sample data in the Power BI Forum&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2024 01:32:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/If-Query-in-Dax/m-p/4300776#M170783</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-26T01:32:44Z</dc:date>
    </item>
  </channel>
</rss>

