<?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 Combine selected value (slicer) with sum for selected period and previous period in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Combine-selected-value-slicer-with-sum-for-selected-period-and/m-p/4103737#M162840</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;I´m wondering if is possible to combine in one matrix these calculated values.&lt;BR /&gt;I need something like this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I will be OK with this format too:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;visual is affected with this slicer:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I try to use two measure in one matrix.&lt;/P&gt;&lt;P&gt;The first one is:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Sum Annualized Booking Value (Selected Year Marker) = 
VAR SelectedYear = 
    SWITCH(
        SELECTEDVALUE(general_date_table[Year Marker]),
        "YTD Marker", YEAR(TODAY()),
        "1 Year Ago", YEAR(TODAY()) - 1,
        "2 Years Ago", YEAR(TODAY()) - 2,
        "3 Years Ago", YEAR(TODAY()) - 3,
        BLANK()
    )

RETURN
CALCULATE(
    [Sum Total Contract Value],
    USERELATIONSHIP(contract_item_history[contract_revision_approved_date], general_date_table[Date]),
    YEAR(contract_item_history[contract_revision_approved_date]) = SelectedYear
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;works perfectly&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the secont one, doesn´t work with the slicer:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;_test_Sum Annualized TCV = 
VAR year_ago = CALCULATE(
    [Sum Total Contract Value],
    FILTER(
        contract_item_history,
        YEAR(contract_item_history[contract_revision_approved_date]) = YEAR(TODAY()) - 1
    )
)
VAR two_years_ago = CALCULATE(
    [Sum Total Contract Value],
    FILTER(
        contract_item_history,
        YEAR(contract_item_history[contract_revision_approved_date]) = YEAR(TODAY()) - 2
    )
)

VAR three_years_ago  = CALCULATE(
    [Sum Total Contract Value],
    FILTER(
        contract_item_history,
        YEAR(contract_item_history[contract_revision_approved_date]) = YEAR(TODAY()) - 3
    )
)

VAR four_years_ago  = CALCULATE(
    [Sum Total Contract Value],
    FILTER(
        contract_item_history,
        YEAR(contract_item_history[contract_revision_approved_date]) = YEAR(TODAY()) - 4
    )
)

VAR _selected_year = SELECTEDVALUE(general_date_table[Year Marker])

RETURN
SWITCH(
    TRUE(),
    _selected_year = "YTD Marker", year_ago,
    _selected_year = "1 Year Ago", two_years_ago,
    _selected_year = "2 Years Ago", three_years_ago,
    _selected_year = "3 Years Ago", four_years_ago,
    "N/A"
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I tried a simple one too, but doesn´t work neither:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;_test Sum for Previous Year =
CALCULATE(
    [Sum Total Contract Value],
    FILTER(
        contract_item_history,
        YEAR(contract_item_history[contract_revision_approved_date]) =
            SWITCH(
                SELECTEDVALUE(general_date_table[Year Marker]),
                "YTD Marker", YEAR(TODAY()) - 1,
                "1 Year Ago", YEAR(TODAY()) - 2,
                "2 Years Ago", YEAR(TODAY()) - 3,
                "3 Years Ago", YEAR(TODAY()) - 4,
                BLANK()
            )
    )
)&amp;lt;p&amp;gt;&amp;lt;br /&amp;gt;Any idea why is not working and how to fix it?&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt; &amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Thanks a lot in advanced&amp;lt;br /&amp;gt;Sona&amp;lt;/p&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Aug 2024 07:02:26 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-08-16T07:02:26Z</dc:date>
    <item>
      <title>Combine selected value (slicer) with sum for selected period and previous period</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Combine-selected-value-slicer-with-sum-for-selected-period-and/m-p/4103737#M162840</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;I´m wondering if is possible to combine in one matrix these calculated values.&lt;BR /&gt;I need something like this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I will be OK with this format too:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;visual is affected with this slicer:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I try to use two measure in one matrix.&lt;/P&gt;&lt;P&gt;The first one is:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Sum Annualized Booking Value (Selected Year Marker) = 
VAR SelectedYear = 
    SWITCH(
        SELECTEDVALUE(general_date_table[Year Marker]),
        "YTD Marker", YEAR(TODAY()),
        "1 Year Ago", YEAR(TODAY()) - 1,
        "2 Years Ago", YEAR(TODAY()) - 2,
        "3 Years Ago", YEAR(TODAY()) - 3,
        BLANK()
    )

RETURN
CALCULATE(
    [Sum Total Contract Value],
    USERELATIONSHIP(contract_item_history[contract_revision_approved_date], general_date_table[Date]),
    YEAR(contract_item_history[contract_revision_approved_date]) = SelectedYear
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;works perfectly&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the secont one, doesn´t work with the slicer:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;_test_Sum Annualized TCV = 
VAR year_ago = CALCULATE(
    [Sum Total Contract Value],
    FILTER(
        contract_item_history,
        YEAR(contract_item_history[contract_revision_approved_date]) = YEAR(TODAY()) - 1
    )
)
VAR two_years_ago = CALCULATE(
    [Sum Total Contract Value],
    FILTER(
        contract_item_history,
        YEAR(contract_item_history[contract_revision_approved_date]) = YEAR(TODAY()) - 2
    )
)

VAR three_years_ago  = CALCULATE(
    [Sum Total Contract Value],
    FILTER(
        contract_item_history,
        YEAR(contract_item_history[contract_revision_approved_date]) = YEAR(TODAY()) - 3
    )
)

VAR four_years_ago  = CALCULATE(
    [Sum Total Contract Value],
    FILTER(
        contract_item_history,
        YEAR(contract_item_history[contract_revision_approved_date]) = YEAR(TODAY()) - 4
    )
)

VAR _selected_year = SELECTEDVALUE(general_date_table[Year Marker])

RETURN
SWITCH(
    TRUE(),
    _selected_year = "YTD Marker", year_ago,
    _selected_year = "1 Year Ago", two_years_ago,
    _selected_year = "2 Years Ago", three_years_ago,
    _selected_year = "3 Years Ago", four_years_ago,
    "N/A"
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I tried a simple one too, but doesn´t work neither:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;_test Sum for Previous Year =
CALCULATE(
    [Sum Total Contract Value],
    FILTER(
        contract_item_history,
        YEAR(contract_item_history[contract_revision_approved_date]) =
            SWITCH(
                SELECTEDVALUE(general_date_table[Year Marker]),
                "YTD Marker", YEAR(TODAY()) - 1,
                "1 Year Ago", YEAR(TODAY()) - 2,
                "2 Years Ago", YEAR(TODAY()) - 3,
                "3 Years Ago", YEAR(TODAY()) - 4,
                BLANK()
            )
    )
)&amp;lt;p&amp;gt;&amp;lt;br /&amp;gt;Any idea why is not working and how to fix it?&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt; &amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Thanks a lot in advanced&amp;lt;br /&amp;gt;Sona&amp;lt;/p&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 07:02:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Combine-selected-value-slicer-with-sum-for-selected-period-and/m-p/4103737#M162840</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-16T07:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: Combine selected value (slicer) with sum for selected period and previous period</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Combine-selected-value-slicer-with-sum-for-selected-period-and/m-p/4104193#M162862</link>
      <description>&lt;P&gt;As soon as you are trying to render different formats (percentages and numbers) you need to either "show values on rows"&amp;nbsp; or have all your measures return text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide sample data &lt;STRONG&gt;that fully covers your issue&lt;/STRONG&gt;.&lt;BR /&gt;Please show the expected outcome based on the sample data you provided.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 12:37:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Combine-selected-value-slicer-with-sum-for-selected-period-and/m-p/4104193#M162862</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-08-16T12:37:26Z</dc:date>
    </item>
  </channel>
</rss>

