<?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 DAX SUMX Summarize Groups over DatesYTD not working in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-SUMX-Summarize-Groups-over-DatesYTD-not-working/m-p/3517900#M135101</link>
    <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm stumbling over a problem now for what seems like half-a-day to no avail.&amp;nbsp; Therefore, I'm hoping someone here can shed some insight that might lead me to my expected result.&amp;nbsp; Thank you in advance if you take the time to read through this issue!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a very simple data-model (the actual one is way more complex, this is the simplified one to avoid real data being posted)&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;The user can select Scenario 1, and Scenario 2 via a slicer (this feature cannot be removed).&amp;nbsp; However, sometimes Scenario 1 will not have results (When aggregated over Category and summed YTD), and thus should not be in the total summation for the final division.&amp;nbsp; The grouping of the result occurs at the Category level, with the figures summed up to the YTD of the Month Slicer (this slicer cannot be removed).&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here you can see the summations (&lt;FONT color="#FF0000"&gt;Scn2&lt;/FONT&gt;, &lt;FONT color="#3366FF"&gt;Scn1&lt;/FONT&gt;) occurring correctly, however, when I do the summation over a summarize with DATESYTD, I'm getting the wrong value (&lt;FONT color="#339966"&gt;Green Circle&lt;/FONT&gt;).&amp;nbsp; The expected result is the image with Green rows above the table with partially right and wrong results.&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;The expected results are shown at the top where I would expect the DatesYTD to work correctly, but for the life of me the summation won't work, to where I can filter out the relevent group-sums.&amp;nbsp; I'm trying to avoid dax'ing a LOOKUPVALUE, as the actual level of dimensions in the real model are quite numerous, whereas in the attached PBIX file its very simple.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;test scn1 = 
VAR _Scn = SELECTEDVALUE('Scenario1'[Scenario1])
VAR _Result =
        CALCULATE( 
            CALCULATE(
                SUM('Fact Table'[Value])
                ,DATESYTD('Master_Calendar'[Date])
            )
            ,'Fact Table'[Scenario] = _Scn
        )

RETURN
    _Result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;test scn2 = 
VAR _Scn = SELECTEDVALUE('Scenario2'[Scenario2])
VAR _Result =
        CALCULATE( 
            CALCULATE(
                SUMX('Fact Table', 'Fact Table'[Value]  )
                ,DATESYTD('Master_Calendar'[Date])
            )
            ,'Fact Table'[Scenario] = _Scn
        )
VAR _Scn1 = [test scn1]

RETURN
    _Result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;test scn2 summarize = 
VAR _Scn = SELECTEDVALUE('Scenario2'[Scenario2])
VAR _Summary =
    FILTER(
        SUMMARIZE(
            'Fact Table'
            ,'Fact Table'[Category]
            ,'Fact Table'[Period]
            ,"Result Scn1", [test scn1]
            ,"Result Scn2", [test scn2]
        )
        ,NOT([Result Scn1] in { Blank(), 0} )
    )
RETURN
    SUMX(_Summary, [Result Scn2])&lt;/LI-CODE&gt;&lt;P&gt;Slightly different version of the above:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;test scn1 summarize = 
VAR _Scn1 = SELECTEDVALUE('Scenario1'[Scenario1])
VAR _Scn2 = SELECTEDVALUE('Scenario2'[Scenario2])
VAR _Summary =
    FILTER(
        SUMMARIZE(
            'Fact Table'
            ,'Fact Table'[Category]
            ,'Fact Table'[Period]
            ,"Result Scn1"       
            ,CALCULATE( 
                CALCULATE(
                    SUM('Fact Table'[Value])
                    ,DATESYTD('Master_Calendar'[Date])
                )
                ,'Fact Table'[Scenario] = _Scn1
            )
            ,"Result Scn2"            
            ,CALCULATE( 
                CALCULATE(
                    SUM('Fact Table'[Value])
                    ,DATESYTD('Master_Calendar'[Date])
                )
                ,'Fact Table'[Scenario] = _Scn2
            )
        )
        ,NOT([Result Scn1] in { Blank(), 0} )
    )
RETURN
    SUMX(_Summary, [Result Scn1])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I realize its an issue with DatesYTD, I've tried numerous other variations, such as FILTER(dates, [Month Number] &amp;lt;= SELECTEDVALUE(dates[Month Number]) ), using GroupBy, SummarizeColumns, and other combinations; however, for the life of me, I'm stuck.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;A href="https://drive.google.com/file/d/1uJaUJqhHFRQcDph0a0KPs6ghkdKFzm6u/view?usp=sharing" target="_self"&gt;PBIX File Here&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any help, and hope you have a great day!&lt;/P&gt;</description>
    <pubDate>Mon, 06 Nov 2023 14:22:30 GMT</pubDate>
    <dc:creator>Mel_Kulek</dc:creator>
    <dc:date>2023-11-06T14:22:30Z</dc:date>
    <item>
      <title>DAX SUMX Summarize Groups over DatesYTD not working</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-SUMX-Summarize-Groups-over-DatesYTD-not-working/m-p/3517900#M135101</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm stumbling over a problem now for what seems like half-a-day to no avail.&amp;nbsp; Therefore, I'm hoping someone here can shed some insight that might lead me to my expected result.&amp;nbsp; Thank you in advance if you take the time to read through this issue!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a very simple data-model (the actual one is way more complex, this is the simplified one to avoid real data being posted)&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;The user can select Scenario 1, and Scenario 2 via a slicer (this feature cannot be removed).&amp;nbsp; However, sometimes Scenario 1 will not have results (When aggregated over Category and summed YTD), and thus should not be in the total summation for the final division.&amp;nbsp; The grouping of the result occurs at the Category level, with the figures summed up to the YTD of the Month Slicer (this slicer cannot be removed).&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here you can see the summations (&lt;FONT color="#FF0000"&gt;Scn2&lt;/FONT&gt;, &lt;FONT color="#3366FF"&gt;Scn1&lt;/FONT&gt;) occurring correctly, however, when I do the summation over a summarize with DATESYTD, I'm getting the wrong value (&lt;FONT color="#339966"&gt;Green Circle&lt;/FONT&gt;).&amp;nbsp; The expected result is the image with Green rows above the table with partially right and wrong results.&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;The expected results are shown at the top where I would expect the DatesYTD to work correctly, but for the life of me the summation won't work, to where I can filter out the relevent group-sums.&amp;nbsp; I'm trying to avoid dax'ing a LOOKUPVALUE, as the actual level of dimensions in the real model are quite numerous, whereas in the attached PBIX file its very simple.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;test scn1 = 
VAR _Scn = SELECTEDVALUE('Scenario1'[Scenario1])
VAR _Result =
        CALCULATE( 
            CALCULATE(
                SUM('Fact Table'[Value])
                ,DATESYTD('Master_Calendar'[Date])
            )
            ,'Fact Table'[Scenario] = _Scn
        )

RETURN
    _Result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;test scn2 = 
VAR _Scn = SELECTEDVALUE('Scenario2'[Scenario2])
VAR _Result =
        CALCULATE( 
            CALCULATE(
                SUMX('Fact Table', 'Fact Table'[Value]  )
                ,DATESYTD('Master_Calendar'[Date])
            )
            ,'Fact Table'[Scenario] = _Scn
        )
VAR _Scn1 = [test scn1]

RETURN
    _Result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;test scn2 summarize = 
VAR _Scn = SELECTEDVALUE('Scenario2'[Scenario2])
VAR _Summary =
    FILTER(
        SUMMARIZE(
            'Fact Table'
            ,'Fact Table'[Category]
            ,'Fact Table'[Period]
            ,"Result Scn1", [test scn1]
            ,"Result Scn2", [test scn2]
        )
        ,NOT([Result Scn1] in { Blank(), 0} )
    )
RETURN
    SUMX(_Summary, [Result Scn2])&lt;/LI-CODE&gt;&lt;P&gt;Slightly different version of the above:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;test scn1 summarize = 
VAR _Scn1 = SELECTEDVALUE('Scenario1'[Scenario1])
VAR _Scn2 = SELECTEDVALUE('Scenario2'[Scenario2])
VAR _Summary =
    FILTER(
        SUMMARIZE(
            'Fact Table'
            ,'Fact Table'[Category]
            ,'Fact Table'[Period]
            ,"Result Scn1"       
            ,CALCULATE( 
                CALCULATE(
                    SUM('Fact Table'[Value])
                    ,DATESYTD('Master_Calendar'[Date])
                )
                ,'Fact Table'[Scenario] = _Scn1
            )
            ,"Result Scn2"            
            ,CALCULATE( 
                CALCULATE(
                    SUM('Fact Table'[Value])
                    ,DATESYTD('Master_Calendar'[Date])
                )
                ,'Fact Table'[Scenario] = _Scn2
            )
        )
        ,NOT([Result Scn1] in { Blank(), 0} )
    )
RETURN
    SUMX(_Summary, [Result Scn1])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I realize its an issue with DatesYTD, I've tried numerous other variations, such as FILTER(dates, [Month Number] &amp;lt;= SELECTEDVALUE(dates[Month Number]) ), using GroupBy, SummarizeColumns, and other combinations; however, for the life of me, I'm stuck.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;A href="https://drive.google.com/file/d/1uJaUJqhHFRQcDph0a0KPs6ghkdKFzm6u/view?usp=sharing" target="_self"&gt;PBIX File Here&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any help, and hope you have a great day!&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 14:22:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-SUMX-Summarize-Groups-over-DatesYTD-not-working/m-p/3517900#M135101</guid>
      <dc:creator>Mel_Kulek</dc:creator>
      <dc:date>2023-11-06T14:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: DAX SUMX Summarize Groups over DatesYTD not working</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-SUMX-Summarize-Groups-over-DatesYTD-not-working/m-p/3518978#M135156</link>
      <description>&lt;P&gt;You essentially want to get a Scenario 1 YTD vs Scenario 2 YTD percent, but only for categories that have data in both scenarios, right? I would take a different approach.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First, especially if performance is a concern, set up physical relationships between the Scenarios and your calendar table. Make these relationships inactive. Get rid of your bidirectional filter. At the end of the day, your scenarios are filtering your calendar table; it's more efficient to filter calendar with scenarios directly rather than through your fact.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can then get what (I think) you want with the following measures:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;test scn1 = 
CALCULATE( 
    SUM( 'Fact Table'[Value] ), 
    CALCULATETABLE( 
        DATESYTD( Master_Calendar[Date] ), 
        USERELATIONSHIP( Master_Calendar[Year], Scenario1[Scenario1] ) 
    )
)

test scn2 = 
CALCULATE( 
    SUM( 'Fact Table'[Value] ), 
    CALCULATETABLE( 
        DATESYTD( Master_Calendar[Date] ), 
        USERELATIONSHIP( Master_Calendar[Year], Scenario2[Scenario2] ) 
    )
)

scn1 v scn2 = 
CALCULATE(
    DIVIDE( [test scn2] - [test scn1], [test scn1] ), 
    // following two filter args will intersect to get cats that have data in both scns
    CALCULATETABLE( 
        VALUES( 'Fact Table'[Category] ), 
        CALCULATETABLE( 
            DATESYTD( Master_Calendar[Date] ), 
            USERELATIONSHIP( Master_Calendar[Year], Scenario1[Scenario1] ) 
        )
    ),
    CALCULATETABLE( 
        VALUES( 'Fact Table'[Category] ), 
        CALCULATETABLE( 
            DATESYTD( Master_Calendar[Date] ), 
            USERELATIONSHIP( Master_Calendar[Year], Scenario2[Scenario2] ) 
        )
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Result:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 03:27:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-SUMX-Summarize-Groups-over-DatesYTD-not-working/m-p/3518978#M135156</guid>
      <dc:creator>MarkLaf</dc:creator>
      <dc:date>2023-11-07T03:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: DAX SUMX Summarize Groups over DatesYTD not working</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-SUMX-Summarize-Groups-over-DatesYTD-not-working/m-p/3519198#M135164</link>
      <description>&lt;P&gt;MarkLaf,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your support.&amp;nbsp; However, this solution won't work.&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;There are multiple scenarios that can exist in a particular year, e.g. 2022 v1, 2022 v2, 2022 v3.&amp;nbsp; I should have clarified that in the original scope, it was overlooked because I was trying to keep everything simple.&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;changing the bi-directional filter will cause a re-write of about 95% of the rest of the report, which I would prefer to avoid. I inherently built the model taking into consideration the multiple scenarios per year, just this particular issue is the one case where it doesn't seemingly work.&amp;nbsp;&amp;nbsp;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do like your solution and for other projects I might incorporate this, it's unfortunate that I cannot use it in its entirety to solve this particular problem.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Mel&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 07:17:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-SUMX-Summarize-Groups-over-DatesYTD-not-working/m-p/3519198#M135164</guid>
      <dc:creator>Mel_Kulek</dc:creator>
      <dc:date>2023-11-07T07:17:29Z</dc:date>
    </item>
  </channel>
</rss>

