<?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: Handling BLANK values in YTD calculation in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Handling-BLANK-values-in-YTD-calculation/m-p/2261451#M54701</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;For basic YTD calculation this pattern should be good: CALCULATE([measure],DATESYTD('Calendar'[Date]))&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;This doesn't run into any issues with blank values. However it is important to use a calendar table, otherwise you will get the black value in YTD measure (example of problem):&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;YTD example = &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;WarehouseHistory[QTY]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;DATESYTD&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'WarehouseHistory'[Date]&lt;/SPAN&gt;&lt;SPAN&gt;))&amp;nbsp;&lt;STRONG&gt;Does not work&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Example data:&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Working example with calendar:&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN&gt;YTD example = &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;WarehouseHistory[QTY]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;DATESYTD&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'calendar'[Date]&lt;/SPAN&gt;&lt;SPAN&gt;)) //&lt;STRONG&gt;works as intended&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;I hope this helps and if it does consider accepting this as a soltuion and giving the post a thumbs up!&lt;/SPAN&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 30 Dec 2021 17:47:11 GMT</pubDate>
    <dc:creator>ValtteriN</dc:creator>
    <dc:date>2021-12-30T17:47:11Z</dc:date>
    <item>
      <title>Handling BLANK values in YTD calculation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Handling-BLANK-values-in-YTD-calculation/m-p/2261407#M54699</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need yiur help.&lt;/P&gt;&lt;P&gt;PROBLEM: in the calculation of YTD value, choosing the month containing blank value, YTD gives blank as well. example: for data ending in 2021-10, choosing in slicer 2021-12, I get null value. I would like to get the YTD amount, so in this example for 2021-12, the amount should be the same as for 2021-10.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FORMULAS I USE:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for YTD Amount:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;AMOUNT YTD = 
var maxDate = max(DATA[Month/Year])
    var YTDDate =
    filter(
        all(DATA[Month/Year]),
        DATA[Month/Year] &amp;lt;= maxDate
    )
        var YTD_Amount = 
        calculate(_Measures[AMOUNT],YTDDate)
return
YTD_Amount&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then I created independant Year-Month table (Year-Month_1 column), to be able to choose the time independantly from the Year-Month.&lt;/P&gt;&lt;P&gt;then I created a new measure, incorporating Year-Month_1:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;AMOUNT_YTD_1 = 
CALCULATE(
    [AMOUNT YTD],
    DATA[Month/Year] IN ALLSELECTED(Date_1[Year-Month_1])
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this logic works perfectly however choosing the year-month_1 date for which there is no Amount (Amount is blank), the whole Amount_YTD_1 is blank as well. I would like to change this and for such year_month_1 date get the Amount_YTD_1 for the the latest data available before the one I chose (like in normal YTD calculation)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you for your help.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Dec 2021 16:57:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Handling-BLANK-values-in-YTD-calculation/m-p/2261407#M54699</guid>
      <dc:creator>Draszor</dc:creator>
      <dc:date>2021-12-30T16:57:59Z</dc:date>
    </item>
    <item>
      <title>Re: Handling BLANK values in YTD calculation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Handling-BLANK-values-in-YTD-calculation/m-p/2261451#M54701</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;For basic YTD calculation this pattern should be good: CALCULATE([measure],DATESYTD('Calendar'[Date]))&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;This doesn't run into any issues with blank values. However it is important to use a calendar table, otherwise you will get the black value in YTD measure (example of problem):&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;YTD example = &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;WarehouseHistory[QTY]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;DATESYTD&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'WarehouseHistory'[Date]&lt;/SPAN&gt;&lt;SPAN&gt;))&amp;nbsp;&lt;STRONG&gt;Does not work&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Example data:&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Working example with calendar:&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN&gt;YTD example = &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;WarehouseHistory[QTY]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;DATESYTD&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'calendar'[Date]&lt;/SPAN&gt;&lt;SPAN&gt;)) //&lt;STRONG&gt;works as intended&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;I hope this helps and if it does consider accepting this as a soltuion and giving the post a thumbs up!&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 30 Dec 2021 17:47:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Handling-BLANK-values-in-YTD-calculation/m-p/2261451#M54701</guid>
      <dc:creator>ValtteriN</dc:creator>
      <dc:date>2021-12-30T17:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: Handling BLANK values in YTD calculation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Handling-BLANK-values-in-YTD-calculation/m-p/2261481#M54706</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;hmm, the logic with DATESYTD seams to work but it does not give me the desired results. My intention is to dynamically change Period 1 and Pwriod 2 and get the variance between those two periods. with my logic it works perfectly if in both chosen periods there is no balnk value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;using DATESYTD, I get the PERIOD 1 YTD column insensitive for my Period 1 choice, showing total YTD values.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Dec 2021 18:26:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Handling-BLANK-values-in-YTD-calculation/m-p/2261481#M54706</guid>
      <dc:creator>Draszor</dc:creator>
      <dc:date>2021-12-30T18:26:41Z</dc:date>
    </item>
    <item>
      <title>Re: Handling BLANK values in YTD calculation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Handling-BLANK-values-in-YTD-calculation/m-p/2262509#M54757</link>
      <description>&lt;P&gt;Hello All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've found the solution to my problem. I post it here, maybe someone finds it helpful.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem was with my AMOUNT_YTD_1 AND AMOUNT_YTD_2 definitions.&lt;/P&gt;&lt;P&gt;originally I defined those measures as:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;AMOUNT_YTD_1 = 
CALCULATE(
    [AMOUNT YTD],
    DATA[Month/Year] IN ALLSELECTED(Date_1[Year-Month_1])
)&lt;/LI-CODE&gt;&lt;P&gt;when I thought about it - for IN ALLSELECTED(), if I chose the Year-Month_1 that did not exist for a given project in Month/Year, then I was getting blank values, even though YTD for this chosen Year-Month_1&amp;nbsp; was not blank (in previous months to the one chosen by me, there were some values.&lt;/P&gt;&lt;P&gt;After the below change, I got the complete values for all projects, even for those not having anything in chosen Year-Month_1:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;AMOUNT_YTD_1 = 
CALCULATE(
    [AMOUNT YTD],
    DATA[Month/Year] &amp;lt;= SELECTEDVALUE(Date_1[Year-Month_1])
)&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 01 Jan 2022 16:33:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Handling-BLANK-values-in-YTD-calculation/m-p/2262509#M54757</guid>
      <dc:creator>Draszor</dc:creator>
      <dc:date>2022-01-01T16:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: Handling BLANK values in YTD calculation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Handling-BLANK-values-in-YTD-calculation/m-p/2264726#M54831</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="227965" data-lia-user-login="Draszor" class="lia-mention lia-mention-user"&gt;Draszor&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you for sharing.&lt;/P&gt;
&lt;P&gt;Could you please mark your post as Answered since it is working now? It will help the others in the community find the solution easily if they face the same problem with you.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jan 2022 04:39:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Handling-BLANK-values-in-YTD-calculation/m-p/2264726#M54831</guid>
      <dc:creator>v-angzheng-msft</dc:creator>
      <dc:date>2022-01-04T04:39:45Z</dc:date>
    </item>
  </channel>
</rss>

