<?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: Creating measures to get the most recent account balance based off slicer date in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-measures-to-get-the-most-recent-account-balance-based/m-p/2608276#M75554</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="208951" data-lia-user-login="zoop" class="lia-mention lia-mention-user"&gt;zoop&lt;/a&gt; , Ideally you should join with date table. Lastnonblankvalue can help &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lastnonblankvalue(Table[Date]), Sum(Table[Balance]) ) &lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/Firstnonblankvalue-and-Lastnonblankvalue/m-p/1218388#M551" target="_blank"&gt;https://community.powerbi.com/t5/Quick-Measures-Gallery/Firstnonblankvalue-and-Lastnonblankvalue/m-p/1218388#M551&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Jun 2022 03:54:35 GMT</pubDate>
    <dc:creator>amitchandak</dc:creator>
    <dc:date>2022-06-29T03:54:35Z</dc:date>
    <item>
      <title>Creating measures to get the most recent account balance based off slicer date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-measures-to-get-the-most-recent-account-balance-based/m-p/2608029#M75545</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently stuck with a problem related to DAX and hoping that someone could please help out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my example I have a table of bank account balances, with the date ('Balance Date', format YYYYMMDD) that the balance was archived in the system. There are three different account types - Savings 1, Savings 2 and Chequing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking to create three measures - one for each bank account type, which will sum the balances based off a date that is selected in a slicer. The caveat is that only the most recent balance should be returned depending on the date in the slicer (e.g. if the slicer date is 20 June, I would only want to return the most recent balance for that account up to that date. The balance is a snapshot at a point in time).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's worth noting that if an easier solution would result from changing the format of the 'Balance Date' to a proper date format and joining onto the DimDate table then that's fine, I have just provided an example of the data I currently have but it is malleable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have included a link to a sample workbook below with expected outputs to help better understand the issue. Any assistance would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.mediafire.com/file/ebi51sncnjhj1hx/Account_Balance_Example.pbix/file" target="_blank"&gt;https://www.mediafire.com/file/ebi51sncnjhj1hx/Account_Balance_Example.pbix/file&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2022 00:05:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-measures-to-get-the-most-recent-account-balance-based/m-p/2608029#M75545</guid>
      <dc:creator>zoop</dc:creator>
      <dc:date>2022-06-29T00:05:33Z</dc:date>
    </item>
    <item>
      <title>Re: Creating measures to get the most recent account balance based off slicer date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-measures-to-get-the-most-recent-account-balance-based/m-p/2608276#M75554</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="208951" data-lia-user-login="zoop" class="lia-mention lia-mention-user"&gt;zoop&lt;/a&gt; , Ideally you should join with date table. Lastnonblankvalue can help &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lastnonblankvalue(Table[Date]), Sum(Table[Balance]) ) &lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/Firstnonblankvalue-and-Lastnonblankvalue/m-p/1218388#M551" target="_blank"&gt;https://community.powerbi.com/t5/Quick-Measures-Gallery/Firstnonblankvalue-and-Lastnonblankvalue/m-p/1218388#M551&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2022 03:54:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-measures-to-get-the-most-recent-account-balance-based/m-p/2608276#M75554</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-06-29T03:54:35Z</dc:date>
    </item>
    <item>
      <title>Re: Creating measures to get the most recent account balance based off slicer date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-measures-to-get-the-most-recent-account-balance-based/m-p/2608321#M75562</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;,&amp;nbsp;thank you for your response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you mean I should join to the date table differently to how I did in my sample workbook? I will have a look into Lastnonblankvalue and how I could use this in my solution. If you have any additional guidance on how I could use this exactly in my sample workbook it would be much appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2022 04:59:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-measures-to-get-the-most-recent-account-balance-based/m-p/2608321#M75562</guid>
      <dc:creator>zoop</dc:creator>
      <dc:date>2022-06-29T04:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: Creating measures to get the most recent account balance based off slicer date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-measures-to-get-the-most-recent-account-balance-based/m-p/2613410#M75861</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="208951" data-lia-user-login="zoop" class="lia-mention lia-mention-user"&gt;zoop&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In fact, you don’t need build relationship between Account_Balances table and DimDate table.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then, you need these two Measures.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Blance In Range = 
VAR selectedDateInt =
    VALUE (
        CALCULATE (
            MAX ( DimDate[DateInt] ),
            FILTER ( ALL ( DimDate ), DimDate[Date] = SELECTEDVALUE ( DimDate[Date] ) )
        )
    )
VAR maxDateEachAccountType =
    CALCULATE (
        MAX ( Account_Balances[Balance Date] ),
        FILTER (
            ALLEXCEPT (
                Account_Balances,
                Account_Balances[Customer],
                Account_Balances[Account Type]
            ),
            Account_Balances[Balance Date] &amp;lt;= selectedDateInt
        )
    )
var distinctCx=DISTINCTCOUNT(Account_Balances[Customer])
VAR BlanceInRange =
SELECTCOLUMNS(
    TOPN (
        distinctCx,
        FILTER ( Account_Balances, Account_Balances[Balance Date] = maxDateEachAccountType ),
        Account_Balances[Balance Date], DESC,
        Account_Balances[Balance], DESC
    ),
    "Balance_",
    [Balance]
)
return SUMX(BlanceInRange,[Balance_])&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SumEachAccountType = SUMX(Account_Balances,[Blance In Range])&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The result looks like this.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, attached the pbix file as reference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is any post helps, then please consider&lt;STRONG&gt; Accept it as the solution&lt;/STRONG&gt; to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Community Support Team _ Caiyun&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2022 06:15:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-measures-to-get-the-most-recent-account-balance-based/m-p/2613410#M75861</guid>
      <dc:creator>v-cazheng-msft</dc:creator>
      <dc:date>2022-07-01T06:15:54Z</dc:date>
    </item>
  </channel>
</rss>

