<?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: one Bar chart with three fact values with a dynamic selected year in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/one-Bar-chart-with-three-fact-values-with-a-dynamic-selected/m-p/4095216#M162517</link>
    <description>&lt;P&gt;But now everything is posted as 2024 figures. Plus Actual Value 1 is the sum of 2022 and 2023 instead of only 2022 when you select 2024 as Selectedyear.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 12 Aug 2024 10:45:55 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-08-12T10:45:55Z</dc:date>
    <item>
      <title>one Bar chart with three fact values with a dynamic selected year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/one-Bar-chart-with-three-fact-values-with-a-dynamic-selected/m-p/4089140#M162289</link>
      <description>&lt;P&gt;Hi everyone, can you help me with the following?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have three fact tables and a dimension named 'Period,' which is the calendar table. The fact tables are called 'Actual,' 'Budget,' and 'SP,' which stands for Strategic Plan.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I create a bar chart that shows the sales over six years: two closed previous years, the current year with the Budget, and the future three years with the Strategic Plan.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first two bars are sourced from the 'Actual' fact table:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CALCULATE&amp;nbsp;(&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SUMX&amp;nbsp;(&amp;nbsp;VALUES&amp;nbsp;(&amp;nbsp;Period[MonthIndex]&amp;nbsp;),&amp;nbsp;SUM ( Actual[Amount] )&amp;nbsp;),&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FILTER&amp;nbsp;(&amp;nbsp;Period,&amp;nbsp;[Date]&amp;nbsp;&amp;gt;=&amp;nbsp;DATE&amp;nbsp;(&amp;nbsp;YEAR&amp;nbsp;(&amp;nbsp;TODAY&amp;nbsp;()&amp;nbsp;)&amp;nbsp;-&amp;nbsp;2,&amp;nbsp;1,&amp;nbsp;1&amp;nbsp;)&amp;nbsp;),&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Period[Year]&amp;nbsp;&amp;lt;&amp;nbsp;YEAR&amp;nbsp;(&amp;nbsp;TODAY&amp;nbsp;()&amp;nbsp;)&lt;BR /&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The third bar represents the current year and is sourced from the 'Budget' table:&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp;(&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;SUMX&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp;(&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;VALUES&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp;(&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;Period[MonthIndex]&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;SUM&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp;(&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;Budget[Amount]&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;FILTER&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp;(&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;Period,&amp;nbsp;[Year]&amp;nbsp;=&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;YEAR&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp;(&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;TODAY&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The last three bars are sourced from the Strategic Plan ('SP'):&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;CALCULATE (&lt;BR /&gt;SUMX ( VALUES ( Period[MonthIndex] ), SUM ( SP[Amount] ) ),&lt;BR /&gt;FILTER ( Period, [Date] &amp;gt;= DATE ( YEAR ( TODAY () ) + 1, 1, 1 ) )&lt;BR /&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the visual filter, I've placed the 'Relative Year' field from 'Period,' which contains the number of years from the current year, and the filter is set to 'above -2.'&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This setup works well, but now the users want to make the current year (the year that shows the budget) dynamic so that they can look back and compare the figures with the present. So the current year with budget needs to be the budget of the selected year. I tried adjusting the "YEAR ( TODAY () )" in all three formulas to use the SelectedValue formula for the year filter in the dashboard, but that way it only shows the budget for the selected year an no previous two years or the three year from Strategic Plan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have an idea of how I can make this work?"&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 11:39:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/one-Bar-chart-with-three-fact-values-with-a-dynamic-selected/m-p/4089140#M162289</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-08T11:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: one Bar chart with three fact values with a dynamic selected year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/one-Bar-chart-with-three-fact-values-with-a-dynamic-selected/m-p/4089162#M162294</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;To make the current year dynamic and allow users to select a year for comparison while still showing the previous two years and the next three years, you can use the SELECTEDVALUE function in DAX to capture the selected year.&lt;/P&gt;
&lt;P&gt;Capture the Selected Year:&lt;BR /&gt;DAX&lt;BR /&gt;VAR SelectedYear = SELECTEDVALUE(Period[Year])&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Calculate the Actuals for the Previous Two Years:&lt;BR /&gt;DAX&lt;BR /&gt;CALCULATE (&lt;BR /&gt;SUMX ( VALUES ( Period[MonthIndex] ), SUM ( Actual[Amount] ) ),&lt;BR /&gt;FILTER ( Period, [Date] &amp;gt;= DATE ( SelectedYear - 2, 1, 1 ) ),&lt;BR /&gt;Period[Year] &amp;lt; SelectedYear&lt;BR /&gt;)&lt;BR /&gt;Calculate the Budget for the Selected Year:&lt;BR /&gt;DAX&lt;BR /&gt;CALCULATE (&lt;BR /&gt;SUMX ( VALUES ( Period[MonthIndex] ), SUM ( Budget[Amount] ) ),&lt;BR /&gt;FILTER ( Period, [Year] = SelectedYear )&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Calculate the Strategic Plan for the Next Three Years:&lt;BR /&gt;DAX&lt;BR /&gt;CALCULATE (&lt;BR /&gt;SUMX ( VALUES ( Period[MonthIndex] ), SUM ( SP[Amount] ) ),&lt;BR /&gt;FILTER ( Period, [Date] &amp;gt;= DATE ( SelectedYear + 1, 1, 1 ) )&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Adjust the Visual Filter: Ensure that the visual filter for 'Relative Year' is set to include the range from SelectedYear - 2 to SelectedYear + 3.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Here is the combined DAX formula for your bar chart:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;VAR SelectedYear = SELECTEDVALUE(Period[Year])&lt;/P&gt;
&lt;P&gt;RETURN&lt;BR /&gt;SWITCH(&lt;BR /&gt;TRUE(),&lt;BR /&gt;Period[Year] = SelectedYear - 2 || Period[Year] = SelectedYear - 1,&lt;BR /&gt;CALCULATE (&lt;BR /&gt;SUMX ( VALUES ( Period[MonthIndex] ), SUM ( Actual[Amount] ) ),&lt;BR /&gt;FILTER ( Period, [Date] &amp;gt;= DATE ( SelectedYear - 2, 1, 1 ) ),&lt;/P&gt;
&lt;P&gt;This approach ensures that the selected year is dynamic and the calculations for the previous two years, the current year, and the next three years are adjusted accordingly.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 11:58:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/one-Bar-chart-with-three-fact-values-with-a-dynamic-selected/m-p/4089162#M162294</guid>
      <dc:creator>bhanu_gautam</dc:creator>
      <dc:date>2024-08-08T11:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: one Bar chart with three fact values with a dynamic selected year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/one-Bar-chart-with-three-fact-values-with-a-dynamic-selected/m-p/4091140#M162365</link>
      <description>&lt;P&gt;Thank you for your reply.&lt;/P&gt;&lt;P&gt;When I do that, I get the same result as I mentioned before. I only see the budget for all years, but no Actuals and no SP data. Also how can I make the relative year filter based on the selected year instead of the current year.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Aug 2024 08:15:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/one-Bar-chart-with-three-fact-values-with-a-dynamic-selected/m-p/4091140#M162365</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-09T08:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: one Bar chart with three fact values with a dynamic selected year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/one-Bar-chart-with-three-fact-values-with-a-dynamic-selected/m-p/4094768#M162500</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try the follow measures:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Actual Value1 = 
VAR __selected_year = SELECTEDVALUE('Period'[Year])
VAR __result =
CALCULATE (
    SUM ( Actual[Amount] ),
    FILTER ( ALL(Period), [Date] &amp;gt;= DATE ( __selected_year - 2, 1, 1 ) ),
    Period[Year] &amp;lt; __selected_year 
) 
RETURN
__result&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Actual Value2 = 
VAR __selected_year = SELECTEDVALUE('Period'[Year])
VAR __result =
CALCULATE (
    SUM ( Actual[Amount] ),
    FILTER ( ALL(Period), [Date] &amp;gt;= DATE ( __selected_year - 1, 1, 1 ) ),
    Period[Year] &amp;lt; __selected_year 
) 
RETURN
__result&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Budget Value = 
VAR __selected_year = SELECTEDVALUE('Period'[Year])
VAR __result =
CALCULATE (
    SUM ( Budget[Amount] ),
    FILTER (ALL( Period), [Year] = __selected_year )
)
RETURN
__result&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Strategic Plan Value = 
VAR __selected_year = SELECTEDVALUE('Period'[Year])
VAR __result =
CALCULATE (
SUM ( SP[Amount] ),
FILTER ( ALL(Period), [Date] &amp;gt;= DATE ( __selected_year + 1, 1, 1 ) )
)
RETURN
__result&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;Best Regards,&lt;BR /&gt;Gao&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Community Support Team&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;If there is any post&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT size="3" color="#008080"&gt;&lt;EM&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;, then please consider&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT size="3"&gt;&lt;FONT color="#008080"&gt;&lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;to help the other members find it more quickly.&lt;BR /&gt;If I misunderstand your needs or you still have problems on it, please feel free to let us know.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT color="#008080"&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT size="3"&gt;Thanks a lot!&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;FONT size="2" color="#FF0000"&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank" rel="noopener nofollow noreferrer"&gt;How to get your questions answered quickly&lt;/A&gt;&amp;nbsp;--&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank" rel="noopener nofollow noreferrer"&gt;&amp;nbsp;How to provide sample data in the Power BI Forum&lt;/A&gt;&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Aug 2024 07:45:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/one-Bar-chart-with-three-fact-values-with-a-dynamic-selected/m-p/4094768#M162500</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-12T07:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: one Bar chart with three fact values with a dynamic selected year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/one-Bar-chart-with-three-fact-values-with-a-dynamic-selected/m-p/4095216#M162517</link>
      <description>&lt;P&gt;But now everything is posted as 2024 figures. Plus Actual Value 1 is the sum of 2022 and 2023 instead of only 2022 when you select 2024 as Selectedyear.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Aug 2024 10:45:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/one-Bar-chart-with-three-fact-values-with-a-dynamic-selected/m-p/4095216#M162517</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-12T10:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: one Bar chart with three fact values with a dynamic selected year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/one-Bar-chart-with-three-fact-values-with-a-dynamic-selected/m-p/4115300#M163340</link>
      <description>&lt;P&gt;I found the solution myself by doing the following (I used the demo file from Gao, thanks for that).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First, duplicate the 'Period' table in Power Query and give it a unique name (in my example, I named it 'Year'). Delete all fields except the 'Year' field. Then, remove all duplicates in the 'Year' field so that all values are unique. You will then have one table named 'Year' with one field named 'Year.'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Next, use the following DAX formulas:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actual Last 2 Years:&lt;/P&gt;&lt;PRE&gt;Actual = &lt;BR /&gt;VAR selected_year = SELECTEDVALUE('Year'[Year])&lt;BR /&gt;RETURN&lt;BR /&gt;CALCULATE (&lt;BR /&gt;SUM(Actual[Amount]),&lt;BR /&gt;FILTER ( Period, [Year] &amp;gt;= YEAR(DATE ( selected_year - 2, 1, 1 ) )),&lt;BR /&gt;Period[Year] &amp;lt; selected_year&lt;BR /&gt;) &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Budget for the Current Year:&lt;/P&gt;&lt;PRE&gt;Budget = &lt;BR /&gt;VAR selected_year = SELECTEDVALUE('Year'[Year])&lt;BR /&gt;RETURN&lt;BR /&gt;CALCULATE (&lt;BR /&gt;SUM(Budget[Amount]),&lt;BR /&gt;FILTER (Period, [Year] = selected_year)&lt;BR /&gt;)&lt;/PRE&gt;&lt;P&gt;Strategic Plan:&lt;/P&gt;&lt;PRE&gt;Strategic Plan Value = &lt;BR /&gt;VAR selected_year = SELECTEDVALUE('Year'[Year])&lt;BR /&gt;RETURN&lt;BR /&gt;CALCULATE (&lt;BR /&gt;SUM(SP[Amount]),&lt;BR /&gt;FILTER (Period, [Date] &amp;gt;= DATE(selected_year + 1, 1, 1))&lt;BR /&gt;)&lt;/PRE&gt;&lt;P&gt;Then, place the 'Year' field from the 'Period' table on the X-axis and the 'Actual,' 'Budget,' and 'Strategic Plan' measures on the Y-axis. Create a year filter using the 'Year' field from the 'Year' table. And you’re done.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again, thanks to Gao for putting me on the right track!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See here the demo file for more info:&amp;nbsp;&lt;A title="Demo file" href="https://www.dropbox.com/scl/fi/erzevv08m79217vsirxq6/demo.pbix?rlkey=1ta7vh0pff5h46uf3z20wllg9&amp;amp;st=f0q1cu7e&amp;amp;dl=0" target="_self"&gt;Demo.pbix&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2024 08:25:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/one-Bar-chart-with-three-fact-values-with-a-dynamic-selected/m-p/4115300#M163340</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-23T08:25:41Z</dc:date>
    </item>
  </channel>
</rss>

