<?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: two related table Year and month in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/two-related-table-Year-and-month/m-p/4025774#M158934</link>
    <description>&lt;P&gt;I would create a calculated column and join it to your calendar table.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;MonthDate = 
VAR _month_nbr = 
    SWITCH(
        TRUE(),
        Sim_Prelevement[month_texte] = "January", 1,
        Sim_Prelevement[month_texte] = "February", 2,
        Sim_Prelevement[month_texte] = "March", 3,
        Sim_Prelevement[month_texte] = "April", 4,
        Sim_Prelevement[month_texte] = "May", 5,
        Sim_Prelevement[month_texte] = "June", 6,
        Sim_Prelevement[month_texte] = "July", 7,
        Sim_Prelevement[month_texte] = "August", 8,
        Sim_Prelevement[month_texte] = "September", 9,
        Sim_Prelevement[month_texte] = "October", 10,
        Sim_Prelevement[month_texte] = "November", 11,
        Sim_Prelevement[month_texte] = "December", 12,
        BLANK()  -- or any other default value you prefer
    )
VAR _result = DATE(Sim_Prelevement[Year], _month_nbr, 1)

RETURN
_result&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 04 Jul 2024 22:53:26 GMT</pubDate>
    <dc:creator>aduguid</dc:creator>
    <dc:date>2024-07-04T22:53:26Z</dc:date>
    <item>
      <title>two related table Year and month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/two-related-table-Year-and-month/m-p/4025675#M158924</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV&gt;Hello, I have two tables (Calendar and Sales). The sales table contains only the month names and the years. I need to calculate the sales according to the year and the month. I have created two relationships: one by year (active) and one by month (inactive). I then created the following measure:&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;CALCULATE(SUM(Sim_Prelevement[Qte]),Sim_Prelevement[Year] = SELECTEDVALUE(Calendrier[Year]),USERELATIONSHIP(Calendrier[Month],Sim_Prelevement[month_texte]))​&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The measure works very well when I select one year in a slicer, but when I select multiple years, the sum of sales by year and month does not display. Is there a measure that can do the job differently?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;img /&gt;&lt;BR /&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 04 Jul 2024 21:41:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/two-related-table-Year-and-month/m-p/4025675#M158924</guid>
      <dc:creator>RedaBi</dc:creator>
      <dc:date>2024-07-04T21:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: two related table Year and month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/two-related-table-Year-and-month/m-p/4025774#M158934</link>
      <description>&lt;P&gt;I would create a calculated column and join it to your calendar table.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;MonthDate = 
VAR _month_nbr = 
    SWITCH(
        TRUE(),
        Sim_Prelevement[month_texte] = "January", 1,
        Sim_Prelevement[month_texte] = "February", 2,
        Sim_Prelevement[month_texte] = "March", 3,
        Sim_Prelevement[month_texte] = "April", 4,
        Sim_Prelevement[month_texte] = "May", 5,
        Sim_Prelevement[month_texte] = "June", 6,
        Sim_Prelevement[month_texte] = "July", 7,
        Sim_Prelevement[month_texte] = "August", 8,
        Sim_Prelevement[month_texte] = "September", 9,
        Sim_Prelevement[month_texte] = "October", 10,
        Sim_Prelevement[month_texte] = "November", 11,
        Sim_Prelevement[month_texte] = "December", 12,
        BLANK()  -- or any other default value you prefer
    )
VAR _result = DATE(Sim_Prelevement[Year], _month_nbr, 1)

RETURN
_result&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 04 Jul 2024 22:53:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/two-related-table-Year-and-month/m-p/4025774#M158934</guid>
      <dc:creator>aduguid</dc:creator>
      <dc:date>2024-07-04T22:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: two related table Year and month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/two-related-table-Year-and-month/m-p/4026226#M158973</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="81736" data-lia-user-login="aduguid" class="lia-mention lia-mention-user"&gt;aduguid&lt;/a&gt;&amp;nbsp;,Thanks for the quick reply, I'll add further.&lt;/P&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="81736" data-lia-user-login="aduguid" class="lia-mention lia-mention-user"&gt;aduguid&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Regarding your question, the 'SELECTEDVALUE' function only returns the value if there is only one non-duplicate value. If you select more than one year, the null value is returned.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/selectedvalue-function-dax" target="_blank"&gt;SELECTEDVALUE function - DAX | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Try this.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;CALCULATE(SUM(Sim_Prelevement[Qte]),Sim_Prelevement[Year] IN VALUES('Calendrier'[Year]),USERELATIONSHIP(Calendrier[Month],Sim_Prelevement[month_texte]))&lt;/LI-CODE&gt;
&lt;P&gt;If there are still problems, please provide the .pbix culture without sensitive data. Or provide simple data and present the expected results as a picture.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Wenbin Zhou&lt;BR /&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jul 2024 05:17:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/two-related-table-Year-and-month/m-p/4026226#M158973</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-07-05T05:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: two related table Year and month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/two-related-table-Year-and-month/m-p/4027059#M159039</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Excellent idea, I really like this tip&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jul 2024 12:44:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/two-related-table-Year-and-month/m-p/4027059#M159039</guid>
      <dc:creator>RedaBi</dc:creator>
      <dc:date>2024-07-05T12:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: two related table Year and month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/two-related-table-Year-and-month/m-p/4027063#M159040</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Indeed, it worked. I knew I had to replace SELECTEDVALUE, but I didn't know with what. Thank you, this information will help me with my future measures&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jul 2024 12:46:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/two-related-table-Year-and-month/m-p/4027063#M159040</guid>
      <dc:creator>RedaBi</dc:creator>
      <dc:date>2024-07-05T12:46:49Z</dc:date>
    </item>
  </channel>
</rss>

