<?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 Day to Day difference in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Day-to-Day-difference/m-p/2658806#M78752</link>
    <description>&lt;P&gt;Hi All,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I am trying to generate a day to day difference and since I only have data on weekdays and that my data lags 1 day I am facing some issues.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I have the following code:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Measure_DTD = 
   VAR vtoday = MAX('Date Table'[Date])
   VAR vyesterday = IF(FORMAT(MAX('Date Table'[Date]), "DDDD")&amp;lt;&amp;gt; "Monday", MAX('Date Table'[Date])-1, MAX('Date Table'[Date])-3)
   VAR vtwodays = IF(FORMAT(MAX('Date Table'[Date]), "DDDD")&amp;lt;&amp;gt; "Monday", MAX('Date Table'[Date])-2,
                    IF(FORMAT(MAX('Date Table'[Date]), "DDDD")&amp;lt;&amp;gt; "Tuesday", MAX('Date Table'[Date])-4,
                    MAX('Date Table'[Date])-5)
   )
Return
    IF(ISBLANK([Measure_MarketValue]),
        BLANK(),
            IF(FORMAT(vtoday,"DDDD") = "Monday",
                CALCULATE([Measure_MarketValue],'Date Table'[Date] = vtoday) - CALCULATE([Measure_MarketValue],'Date Table'[Date] = vyesterday),

                    IF(FORMAT(vtoday, "DDDD") = "Tuesday",
                    CALCULATE([Measure_MarketValue], 'Date Table'[Date] = vtoday) - CALCULATE([Measure_MarketValue], 'Date Table'[Date] = vyesterday),
                    CALCULATE([Measure_MarketValue], 'Date Table'[Date] = vtoday) - CALCULATE([Measure_MarketValue], 'Date Table'[Date] = vyesterday)
                    )
            )
        )&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Which generates the following output (Sometimes I need to show the latest 3 days with data in it and sometimes I need to show the latest 10 days i.e.)&lt;BR /&gt;&lt;img /&gt;&lt;BR /&gt;As you see the oldest date does not generate the DtD (Day to Day difference) column correctly. Does anyone know how to solve this? (I also have a column named Isweekday as a filter, which is a true/false).&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you in advance.&amp;nbsp;&lt;BR /&gt;Solle&lt;/P&gt;</description>
    <pubDate>Mon, 25 Jul 2022 10:13:39 GMT</pubDate>
    <dc:creator>Solle</dc:creator>
    <dc:date>2022-07-25T10:13:39Z</dc:date>
    <item>
      <title>Day to Day difference</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Day-to-Day-difference/m-p/2658806#M78752</link>
      <description>&lt;P&gt;Hi All,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I am trying to generate a day to day difference and since I only have data on weekdays and that my data lags 1 day I am facing some issues.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I have the following code:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Measure_DTD = 
   VAR vtoday = MAX('Date Table'[Date])
   VAR vyesterday = IF(FORMAT(MAX('Date Table'[Date]), "DDDD")&amp;lt;&amp;gt; "Monday", MAX('Date Table'[Date])-1, MAX('Date Table'[Date])-3)
   VAR vtwodays = IF(FORMAT(MAX('Date Table'[Date]), "DDDD")&amp;lt;&amp;gt; "Monday", MAX('Date Table'[Date])-2,
                    IF(FORMAT(MAX('Date Table'[Date]), "DDDD")&amp;lt;&amp;gt; "Tuesday", MAX('Date Table'[Date])-4,
                    MAX('Date Table'[Date])-5)
   )
Return
    IF(ISBLANK([Measure_MarketValue]),
        BLANK(),
            IF(FORMAT(vtoday,"DDDD") = "Monday",
                CALCULATE([Measure_MarketValue],'Date Table'[Date] = vtoday) - CALCULATE([Measure_MarketValue],'Date Table'[Date] = vyesterday),

                    IF(FORMAT(vtoday, "DDDD") = "Tuesday",
                    CALCULATE([Measure_MarketValue], 'Date Table'[Date] = vtoday) - CALCULATE([Measure_MarketValue], 'Date Table'[Date] = vyesterday),
                    CALCULATE([Measure_MarketValue], 'Date Table'[Date] = vtoday) - CALCULATE([Measure_MarketValue], 'Date Table'[Date] = vyesterday)
                    )
            )
        )&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Which generates the following output (Sometimes I need to show the latest 3 days with data in it and sometimes I need to show the latest 10 days i.e.)&lt;BR /&gt;&lt;img /&gt;&lt;BR /&gt;As you see the oldest date does not generate the DtD (Day to Day difference) column correctly. Does anyone know how to solve this? (I also have a column named Isweekday as a filter, which is a true/false).&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you in advance.&amp;nbsp;&lt;BR /&gt;Solle&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2022 10:13:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Day-to-Day-difference/m-p/2658806#M78752</guid>
      <dc:creator>Solle</dc:creator>
      <dc:date>2022-07-25T10:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: Day to Day difference</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Day-to-Day-difference/m-p/2659105#M78769</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="371558" data-lia-user-login="Solle" class="lia-mention lia-mention-user"&gt;Solle&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Instead of doing all kinds of acrobactics in your code (which you won't understand or remember in a week's time), isn't it better to make the model easier to work with in the first place?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"I am trying to generate a day to day difference and since I only have data on weekdays and that my data lags 1 day I am facing some issues."&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So, if you have data only on weekdays, extend the data so that it's also there on weekends. If your data lags 1 day, then make it so that it does not. Could that not be much easier than that? Please use Power Query to put the data in a shape that will make your journey with DAX a pleasure.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2022 12:14:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Day-to-Day-difference/m-p/2659105#M78769</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-07-25T12:14:09Z</dc:date>
    </item>
    <item>
      <title>Re: Day to Day difference</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Day-to-Day-difference/m-p/2659145#M78775</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="349489" data-lia-user-login="daXtreme" class="lia-mention lia-mention-user"&gt;daXtreme&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you for your reply! I am sadly not in a place where I can modify my data that much, as I am requesting from a SQL Database. However I have a proper date table, which contains a lot of different information related to dates.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The reason why the data is lagging is that i.e. Today I am able to generate the market values from yesterday, since the day has to go past such that I am able to calculate prices, for the whole portfolio.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I am not a strong DAX coder and I am fairly new to PowerBI, so I am trying to learn as much as possible. You do not have any proper DAX solution to my problem, as I am not able to modify my data that much?&lt;BR /&gt;&lt;BR /&gt;Thank you.&lt;BR /&gt;Solle&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2022 12:41:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Day-to-Day-difference/m-p/2659145#M78775</guid>
      <dc:creator>Solle</dc:creator>
      <dc:date>2022-07-25T12:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: Day to Day difference</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Day-to-Day-difference/m-p/2661532#M78934</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="349489" data-lia-user-login="daXtreme" class="lia-mention lia-mention-user"&gt;daXtreme&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I just went through my DAX Calculations and tried to simplify it a bit. What I ended up with is first a measure to generate the previous day MV which is as follows:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Measure_Previous Visible Date MV = 
VAR ___currentDate = MAX( 'Date Table'[Date] )
VAR ___previousVisibleDate = 
            IF (NOT ISBLANK( [Measure_MarketValue] ),
                    CALCULATE ( 
                        MAX ('Date Table'[Date] ),
                        'Date Table'[Date] &amp;lt; ___currentDate
                    )
                )
            VAR ___previousVisibleDateMV = 
            CALCULATE ( [Measure_MarketValue],
                'Date Table'[Date] = ___previousVisibleDate
            )
RETURN
    IF ( NOT ISBLANK( [Measure_MarketValue] ), ___previousVisibleDateMV )&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Then I created a measure to generate the difference between T and T-1 with the following code:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Measure_MV DtD = 
IF(NOT ISBLANK([Measure_Previous Visible Date MV]), 
    CALCULATE([Measure_MarketValue]) - CALCULATE([Measure_Previous Visible Date MV]))&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;However this still provides me with blank at the end of the dates in place:&amp;nbsp;&lt;BR /&gt;&lt;img /&gt;&lt;BR /&gt;&lt;BR /&gt;Do you know how to solve this, with this more simpler code?&lt;BR /&gt;&lt;BR /&gt;Thank you.&amp;nbsp;&lt;BR /&gt;Solle&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2022 09:56:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Day-to-Day-difference/m-p/2661532#M78934</guid>
      <dc:creator>Solle</dc:creator>
      <dc:date>2022-07-26T09:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: Day to Day difference</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Day-to-Day-difference/m-p/2665072#M79164</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="371558" data-lia-user-login="Solle" class="lia-mention lia-mention-user"&gt;Solle&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As far as I know, even data coming from SQL can be modified and you can add to it via DAX (instead of Power Query). You just have to turn your model into a composite one. Then you'll be able to mix imported and remote tables in one model. Just try to read upon "composite models" in Microsoft's documentation on Power BI.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have to modify a date table, it's even easier because such a table can be imported into a composite model and you can then do whatever you like with it. So, for instance, you could add a column which will have days shifted by 1 day forward or backward.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I have a challenge that requires a lot of DAX wizardry... I always back off and think about my model. Because it's the model that you should adjust, not the code. Code should always be simple and the model should always facilitate simple calculations. Simple means understandable and fast. If you start creating complex DAX, you'll be in for a surprise sooner rather than later.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;By the way, measures are always IMPLICITLY wrapped in CALCULATE by the engine itself. You don't have to do it explicitly.&amp;nbsp;&lt;/EM&gt;For instance, you don't have to use CALCULATE in this expression:&lt;/P&gt;&lt;PRE&gt;CALCULATE([Measure_MarketValue]) - CALCULATE([Measure_Previous Visible Date MV])&lt;/PRE&gt;&lt;P&gt;It's the same as using only the bare-bone measures themselves.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jul 2022 13:16:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Day-to-Day-difference/m-p/2665072#M79164</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-07-27T13:16:50Z</dc:date>
    </item>
    <item>
      <title>Re: Day to Day difference</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Day-to-Day-difference/m-p/2667144#M79341</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="371558" data-lia-user-login="Solle" class="lia-mention lia-mention-user"&gt;Solle&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to my knowledge, this situation may be caused by the filter "Date Calendar".&lt;/P&gt;
&lt;P&gt;Please try to use the slicer instead of the filter and then test the following measure:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure_Previous Visible Date MV =

VAR ___currentDate = MAX( 'Date Table'[Date] )

VAR ___previousVisibleDate =

                    CALCULATE (

                        MAX ('Date Table'[Date] ),

                        FILTER(ALL('Date Table'),

                        'Date Table'[Date] &amp;lt; ___currentDate))

VAR ___previousVisibleDateMV =

            CALCULATE ( [Measure_MarketValue],

                Filter('Date Table',

 'Date Table' [Date] = ___previousVisibleDate

            ))

RETURN

IF ( NOT ISBLANK( [Measure_MarketValue] ), ___previousVisibleDateMV )

&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Measure_MV DtD =

IF(NOT ISBLANK([Measure_Previous Visible Date MV]),

[Measure_MarketValue] - [Measure_Previous Visible Date MV])&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this does not work, please provide me with more details about your table and your problem or share me with your pbix file after &lt;STRONG&gt;removing sensitive data&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;Refer to:&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%7Cv-jianboli%40microsoft.com%7Cd07496a2caef4c14ee5d08da6e13a57f%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637943327917507206%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=qa2KRhweo4gIMPLhto3MMG3FZFZDgaND7M32AxCMfG4%3D&amp;amp;reserved=0" target="_blank"&gt;How to provide sample data in the Power BI Forum&lt;/A&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-Get-Your-Question-Answered-Quickly%2Fba-p%2F38490&amp;amp;data=05%7C01%7Cv-jianboli%40microsoft.com%7Cd07496a2caef4c14ee5d08da6e13a57f%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637943327917507206%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=fQIsKU%2Bj99m4YA%2FEKMb0PR%2F89vUPWqb6r5QLdZRFAGU%3D&amp;amp;reserved=0" target="_blank"&gt;How to Get Your Question Answered Quickly&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Jianbo Li&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;/EM&gt;, then please consider&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2022 10:41:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Day-to-Day-difference/m-p/2667144#M79341</guid>
      <dc:creator>v-jianboli-msft</dc:creator>
      <dc:date>2022-07-28T10:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: Day to Day difference</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Day-to-Day-difference/m-p/2680339#M80257</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="371558" data-lia-user-login="Solle" class="lia-mention lia-mention-user"&gt;Solle&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or if you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file after&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;removing sensitive data.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Refer to:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank" rel="noopener"&gt;How to provide sample data in the Power BI Forum&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank" rel="noopener"&gt;How to Get Your Question Answered Quickly&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Jianbo Li&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;/EM&gt;, then please consider&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 02:19:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Day-to-Day-difference/m-p/2680339#M80257</guid>
      <dc:creator>v-jianboli-msft</dc:creator>
      <dc:date>2022-08-04T02:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: Day to Day difference</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Day-to-Day-difference/m-p/2680678#M80270</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="403972" data-lia-user-login="v-jianboli-msft" class="lia-mention lia-mention-user"&gt;v-jianboli-msft&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Sorry for the late reply I was on holiday! But that solved my issue, appreciate your help alot thank you!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Do you know how to generate a monday to monday difference for each week (please be aware that the data is aggregated in the weekly view) So I have the total amount for the whole week on monday so it should just subtract current monday vs last week monday values (not sum the values)&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I have attached an Excel print&lt;BR /&gt;&lt;img /&gt;&lt;BR /&gt;Best Regards,&lt;BR /&gt;Solle&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 06:48:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Day-to-Day-difference/m-p/2680678#M80270</guid>
      <dc:creator>Solle</dc:creator>
      <dc:date>2022-08-04T06:48:15Z</dc:date>
    </item>
  </channel>
</rss>

