<?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: Issues with dax formula using date snapshots in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Issues-with-dax-formula-using-date-snapshots/m-p/4366092#M173361</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="371784" data-lia-user-login="Cadams" class="lia-mention lia-mention-user"&gt;Cadams&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I think you can try to use this DAX code:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Pipeline (Created) =
VAR SelectedSnapshotDate = MAX('Billed Pipeline Snapshot'[Snapshot Date])

VAR LatestSnapshotDate = CALCULATE(MAX('Billed Pipeline Snapshot'[Snapshot Date]), ALL('Billed Pipeline Snapshot'))

VAR SelectedSnapshot =
CALCULATETABLE(
    'Billed Pipeline Snapshot',
    'Billed Pipeline Snapshot'[Snapshot Date] = SelectedSnapshotDate
)

VAR LatestSnapshot =
CALCULATETABLE(
    'Billed Pipeline Snapshot',
    'Billed Pipeline Snapshot'[Snapshot Date] = LatestSnapshotDate
)

VAR AddedOpportunities =
EXCEPT(
    SELECTCOLUMNS(SelectedSnapshot, "OpportunityID", 'Billed Pipeline Snapshot'[Opportunity ID]),
    SELECTCOLUMNS(LatestSnapshot, "OpportunityID", 'Billed Pipeline Snapshot'[Opportunity ID])
)

RETURN
IF (
    ISFILTERED('Billed Pipeline Snapshot'[Snapshot Date]),
    SUMX(
        FILTER(SelectedSnapshot, 'Billed Pipeline Snapshot'[Opportunity ID] IN AddedOpportunities),
        'Billed Pipeline Snapshot'[Pipeline]
    ),
    BLANK()
)&lt;/LI-CODE&gt;
&lt;P&gt;Please provide example data and .pbix files if you can, so that the problem can be solved in a more in-depth study.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Yilong Zhou&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;helps&lt;/I&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Jan 2025 02:26:21 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2025-01-16T02:26:21Z</dc:date>
    <item>
      <title>Issues with dax formula using date snapshots</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Issues-with-dax-formula-using-date-snapshots/m-p/4365565#M173341</link>
      <description>&lt;P&gt;Good afternoon all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been trying for hours and cannot seem to get this formula to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've built a powerbi with snapshots, where the snapshots are a combined set of CSV files that are merged together (all have the same column names etc) with an additional column that labels the date of snapshot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I'm trying to do is calculate which sales opportunities have been created between the very latest snapshot and the snapshot date that I filter based on a slicer (for this example, I've got a snapshot for 30/12, 06/01, 13/01 - where 13/01 is the latest snapshot).&lt;BR /&gt;&lt;BR /&gt;The formula below works and calculates correctly. The only problem I have is that when I select the snapshot date, it is always compares the selected snapshot against the previous date (e.g. when I select 06/01, it compares 06/01 against 30/12), instead of comparing the selected snapshot against the latest snapshot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;What it should do is:&lt;/STRONG&gt;&lt;/U&gt;&lt;BR /&gt;&lt;BR /&gt;if I select 06/01, it should compare 06/01 to 13/01&lt;/P&gt;&lt;P&gt;If I select 30/12, it should compare 30/12 to 13/01&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried changing the formula to show only the latest snapshot with this:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;LatestSnapshotDate = &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;MAX&lt;/SPAN&gt;&lt;SPAN&gt;('Billed Pipeline Snapshot'[Snapshot Date]), &lt;/SPAN&gt;&lt;SPAN&gt;ALL&lt;/SPAN&gt;&lt;SPAN&gt;('Billed Pipeline Snapshot'))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;and&lt;BR /&gt;VAR SelectedSnapShotDate =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;MAX('Billed Pipeline Snapshot'[Snapshot Date]),&lt;BR /&gt;FILTER('Billed Pipeline Snapshot', 'Billed Pipeline Snapshot'[Snapshot Date] &amp;lt; SelectedSnapshotDate)&lt;BR /&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;But this just returns nothing.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Can anyone help me solve this please? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;U&gt;&lt;STRONG&gt;Original formula:&lt;/STRONG&gt;&lt;/U&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;Pipeline (Created) =&lt;BR /&gt;VAR SelectedSnapshotDate = MAX('Billed Pipeline Snapshot'[Snapshot Date])&lt;/P&gt;&lt;P&gt;VAR PreviousSnapshotDate =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;MAX('Billed Pipeline Snapshot'[Snapshot Date]),&lt;BR /&gt;FILTER(ALL('Billed Pipeline Snapshot'), 'Billed Pipeline Snapshot'[Snapshot Date] &amp;lt; SelectedSnapshotDate)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;VAR SelectedSnapshot =&lt;BR /&gt;CALCULATETABLE(&lt;BR /&gt;'Billed Pipeline Snapshot',&lt;BR /&gt;'Billed Pipeline Snapshot'[Snapshot Date] = SelectedSnapshotDate&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;VAR PreviousSnapshot =&lt;BR /&gt;CALCULATETABLE(&lt;BR /&gt;'Billed Pipeline Snapshot',&lt;BR /&gt;'Billed Pipeline Snapshot'[Snapshot Date] = PreviousSnapshotDate&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;VAR AddedOpportunities =&lt;BR /&gt;EXCEPT(&lt;BR /&gt;SELECTCOLUMNS(SelectedSnapshot, "OpportunityID", 'Billed Pipeline Snapshot'[Opportunity ID]),&lt;BR /&gt;SELECTCOLUMNS(PreviousSnapshot, "OpportunityID", 'Billed Pipeline Snapshot'[Opportunity ID])&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;RETURN&lt;BR /&gt;IF (&lt;BR /&gt;ISFILTERED('Billed Pipeline Snapshot'[Snapshot Date]),&lt;BR /&gt;SUMX(&lt;BR /&gt;FILTER(SelectedSnapshot, 'Billed Pipeline Snapshot'[Opportunity ID] IN AddedOpportunities),&lt;BR /&gt;'Billed Pipeline Snapshot'[Pipeline]&lt;BR /&gt;),&lt;BR /&gt;BLANK()&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2025 17:29:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Issues-with-dax-formula-using-date-snapshots/m-p/4365565#M173341</guid>
      <dc:creator>Cadams</dc:creator>
      <dc:date>2025-01-15T17:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with dax formula using date snapshots</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Issues-with-dax-formula-using-date-snapshots/m-p/4366092#M173361</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="371784" data-lia-user-login="Cadams" class="lia-mention lia-mention-user"&gt;Cadams&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I think you can try to use this DAX code:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Pipeline (Created) =
VAR SelectedSnapshotDate = MAX('Billed Pipeline Snapshot'[Snapshot Date])

VAR LatestSnapshotDate = CALCULATE(MAX('Billed Pipeline Snapshot'[Snapshot Date]), ALL('Billed Pipeline Snapshot'))

VAR SelectedSnapshot =
CALCULATETABLE(
    'Billed Pipeline Snapshot',
    'Billed Pipeline Snapshot'[Snapshot Date] = SelectedSnapshotDate
)

VAR LatestSnapshot =
CALCULATETABLE(
    'Billed Pipeline Snapshot',
    'Billed Pipeline Snapshot'[Snapshot Date] = LatestSnapshotDate
)

VAR AddedOpportunities =
EXCEPT(
    SELECTCOLUMNS(SelectedSnapshot, "OpportunityID", 'Billed Pipeline Snapshot'[Opportunity ID]),
    SELECTCOLUMNS(LatestSnapshot, "OpportunityID", 'Billed Pipeline Snapshot'[Opportunity ID])
)

RETURN
IF (
    ISFILTERED('Billed Pipeline Snapshot'[Snapshot Date]),
    SUMX(
        FILTER(SelectedSnapshot, 'Billed Pipeline Snapshot'[Opportunity ID] IN AddedOpportunities),
        'Billed Pipeline Snapshot'[Pipeline]
    ),
    BLANK()
)&lt;/LI-CODE&gt;
&lt;P&gt;Please provide example data and .pbix files if you can, so that the problem can be solved in a more in-depth study.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Yilong Zhou&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;helps&lt;/I&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2025 02:26:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Issues-with-dax-formula-using-date-snapshots/m-p/4366092#M173361</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-01-16T02:26:21Z</dc:date>
    </item>
  </channel>
</rss>

