<?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 Previous period sales based on choosen granularity in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-period-sales-based-on-choosen-granularity/m-p/4263885#M168996</link>
    <description>&lt;P&gt;I would like to create a measure which will calculate sales for previous period based on choosen granularity.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I followed: &lt;A href="https://www.youtube.com/watch?v=hilfglpKNRQ" target="_self"&gt;https://www.youtube.com/watch?v=hilfglpKNRQ&lt;/A&gt; to create granularity and slicer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;first table is connected with slicer with visual table and this table should recalculate appropriately the sales for previous period based on selection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I started to create a measure:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Sales Previous Period = 
VAR SelectedType = SELECTEDVALUE('hlp_Dynamic Date Selections'[Type])

RETURN
SWITCH(
    TRUE(),
    SelectedType = "Y", 
        CALCULATE(
            [Sales]
        )
)&lt;/LI-CODE&gt;&lt;P&gt;but when I refer to dimCalendar or use time intelligence functions the result does not show. How to achieve such functionality?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://drive.google.com/file/d/15UslwRjGZy-yEifeGWuSPq7_BPcB_yV-/view?usp=sharing" target="_self"&gt;https://drive.google.com/file/d/15UslwRjGZy-yEifeGWuSPq7_BPcB_yV-/view?usp=sharing&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Oct 2024 12:44:26 GMT</pubDate>
    <dc:creator>gumis_rulez</dc:creator>
    <dc:date>2024-10-30T12:44:26Z</dc:date>
    <item>
      <title>Previous period sales based on choosen granularity</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-period-sales-based-on-choosen-granularity/m-p/4263885#M168996</link>
      <description>&lt;P&gt;I would like to create a measure which will calculate sales for previous period based on choosen granularity.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I followed: &lt;A href="https://www.youtube.com/watch?v=hilfglpKNRQ" target="_self"&gt;https://www.youtube.com/watch?v=hilfglpKNRQ&lt;/A&gt; to create granularity and slicer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;first table is connected with slicer with visual table and this table should recalculate appropriately the sales for previous period based on selection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I started to create a measure:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Sales Previous Period = 
VAR SelectedType = SELECTEDVALUE('hlp_Dynamic Date Selections'[Type])

RETURN
SWITCH(
    TRUE(),
    SelectedType = "Y", 
        CALCULATE(
            [Sales]
        )
)&lt;/LI-CODE&gt;&lt;P&gt;but when I refer to dimCalendar or use time intelligence functions the result does not show. How to achieve such functionality?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://drive.google.com/file/d/15UslwRjGZy-yEifeGWuSPq7_BPcB_yV-/view?usp=sharing" target="_self"&gt;https://drive.google.com/file/d/15UslwRjGZy-yEifeGWuSPq7_BPcB_yV-/view?usp=sharing&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2024 12:44:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-period-sales-based-on-choosen-granularity/m-p/4263885#M168996</guid>
      <dc:creator>gumis_rulez</dc:creator>
      <dc:date>2024-10-30T12:44:26Z</dc:date>
    </item>
    <item>
      <title>Re: Previous period sales based on choosen granularity</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-period-sales-based-on-choosen-granularity/m-p/4263996#M168998</link>
      <description>&lt;P&gt;You need to remove the filters on the helper table as well as manipulating the dates in the date table.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Sales Previous Period = 
VAR SelectedType = SELECTEDVALUE('hlp_Dynamic Date Selections'[Type])
VAR PrevYear = DATEADD( dimCalendar[Date], -1, YEAR )
VAR PrevQuarter = DATEADD( dimCalendar[Date], -1, QUARTER )
VAR PrevMonth = DATEADD( dimCalendar[Date], -1, MONTH )
VAR PrevWeek = DATEADD( dimCalendar[Date], -7, DAY )
VAR PrevDay = DATEADD( dimCalendar[Date], -1, DAY )

VAR Result = SWITCH( SelectedType,
	"Y",
	CALCULATE( 
		[Sales], 
		PrevYear,
		REMOVEFILTERS( 'hlp_Dynamic Date Selections' )
	),
	"Q",
	CALCULATE( 
		[Sales], 
		PrevQuarter,
		REMOVEFILTERS( 'hlp_Dynamic Date Selections' )
	),
	"M",
	CALCULATE( 
		[Sales], 
		PrevMonth,
		REMOVEFILTERS( 'hlp_Dynamic Date Selections' )
	),
	"W",
	CALCULATE( 
		[Sales], 
		PrevWeek,
		REMOVEFILTERS( 'hlp_Dynamic Date Selections' )
	),
	"D",
	CALCULATE( 
		[Sales], 
		PrevDay,
		REMOVEFILTERS( 'hlp_Dynamic Date Selections' )
	)
)
RETURN Result

&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 30 Oct 2024 14:00:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-period-sales-based-on-choosen-granularity/m-p/4263996#M168998</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2024-10-30T14:00:49Z</dc:date>
    </item>
  </channel>
</rss>

