<?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: Pass two Date Ranges into DAX Formula in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Pass-two-Date-Ranges-into-DAX-Formula/m-p/747922#M2572</link>
    <description>&lt;P&gt;Would you have any suggestions on how to best utilize INTERSET in this scenario? I don't quite see how that function fits as a replacement for TREATAS. We're using a tabular model.&lt;/P&gt;</description>
    <pubDate>Wed, 24 Jul 2019 13:56:30 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-07-24T13:56:30Z</dc:date>
    <item>
      <title>Pass two Date Ranges into DAX Formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Pass-two-Date-Ranges-into-DAX-Formula/m-p/743580#M2393</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My client wants to be able to input two dates to calculate sales for two periods, and then calculate the Delta %. The problem I'm having is how to incorporate two Date Parameters into the Delta formula (the Before &amp;amp; After periods).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To calculate the Delta formula, I want to take "Gross Sales P2" - "Gross Sales P1" / "Gross Sales P1". My thought was to somehow pass both date parameters into a single DAX formula to calculate this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One idea I've had is to create two dynamic tables based on the two date ranges, and then reference those tables in the formula. But I don't know how to do that. We're connected to a SQL Server Analysis Services cube so I don't quite have the option of easily editing the data on the backend. We have a robust Calendar table to work with though.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My screenshot better explains what I'm looking at.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 15:37:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Pass-two-Date-Ranges-into-DAX-Formula/m-p/743580#M2393</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-18T15:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: Pass two Date Ranges into DAX Formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Pass-two-Date-Ranges-into-DAX-Formula/m-p/743592#M2395</link>
      <description>&lt;PRE&gt;Growth % =
var __periodBefore =
	TREATAS(
		VALUES( BeforeSlicer[Date] ),
		'Dates'[Date]
	)
var __periodAfter =
	TREATAS(
		VALUES( AfterSlicer[Date] ),
		'Dates'[Date]
	)	
var __beforeGrossSales =
	CALCULATE(
		[Gross Sales],
		__periodBefore
	)
var __afterGrossSales =
	CALCULATE(
		[Gross Sales],
		__afterPeriod
	)
var __growth =
	DIVIDE(
		__afterGrossSales - __beforeGrossSales,
		__beforeGrossSales
	)
RETURN
	__growth&lt;/PRE&gt;&lt;P&gt;Best&lt;/P&gt;&lt;P&gt;Darek&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 15:45:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Pass-two-Date-Ranges-into-DAX-Formula/m-p/743592#M2395</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-18T15:45:49Z</dc:date>
    </item>
    <item>
      <title>Re: Pass two Date Ranges into DAX Formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Pass-two-Date-Ranges-into-DAX-Formula/m-p/743624#M2402</link>
      <description>&lt;P&gt;EDIT: I'm using Analysis Services for my data source, so it appears these functions are not available to me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Darak - I track with your code, but I'm not able to create variables or use the TREATAS function when creating a DAX formula in Power BI Desktop. Am I doing something wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 16:26:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Pass-two-Date-Ranges-into-DAX-Formula/m-p/743624#M2402</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-18T16:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: Pass two Date Ranges into DAX Formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Pass-two-Date-Ranges-into-DAX-Formula/m-p/743682#M2409</link>
      <description>&lt;P&gt;Well, whether or not you can use a function depends on the version of the SSAS. I hope you're using SSAS Tabular... not Multidimensional. If a function is not available, then you'll have to reformulate the code in such a way that it does the same thing but uses only the available constructs. TREATAS can be replaced by a construct with INTERSECT or, if the version does not support it, with CONTAINS. But pay attention to syntax.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bestk&lt;/P&gt;&lt;P&gt;Dare&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 17:12:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Pass-two-Date-Ranges-into-DAX-Formula/m-p/743682#M2409</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-18T17:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: Pass two Date Ranges into DAX Formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Pass-two-Date-Ranges-into-DAX-Formula/m-p/747922#M2572</link>
      <description>&lt;P&gt;Would you have any suggestions on how to best utilize INTERSET in this scenario? I don't quite see how that function fits as a replacement for TREATAS. We're using a tabular model.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2019 13:56:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Pass-two-Date-Ranges-into-DAX-Formula/m-p/747922#M2572</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-24T13:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: Pass two Date Ranges into DAX Formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Pass-two-Date-Ranges-into-DAX-Formula/m-p/748006#M2573</link>
      <description>&lt;PRE&gt;Growth % =
var __periodBefore =
	INTERSECT(
		VALUES( BeforeSlicer[Date] ),&lt;BR /&gt;-- You might need to replace ALL (...) with VALUES(...) depending on what your needs are.&lt;BR /&gt;-- If you do, then it means you'll respect any existing selections on the Dates dimension.&lt;BR /&gt;-- Using ALL ( ... ) only transfers the selection from BeforeSlicer and removes any filters&lt;BR /&gt;-- coming from Dates itself. You have to decide which behviour fits your req's. Same is&lt;BR /&gt;-- true for the AfterSlicer.
		ALL( 'Dates'[Date] ) 
	)
var __periodAfter =
	INTERSECT(
		VALUES( AfterSlicer[Date] ),
		ALL ( 'Dates'[Date] )
	)	
var __beforeGrossSales =
	CALCULATE(
		[Gross Sales],
		__periodBefore
	)
var __afterGrossSales =
	CALCULATE(
		[Gross Sales],
		__afterPeriod
	)
var __growth =
	DIVIDE(
		__afterGrossSales - __beforeGrossSales,
		__beforeGrossSales
	)
RETURN
	__growth&lt;/PRE&gt;&lt;P&gt;Best&lt;/P&gt;&lt;P&gt;Darek&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2019 15:02:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Pass-two-Date-Ranges-into-DAX-Formula/m-p/748006#M2573</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-24T15:02:49Z</dc:date>
    </item>
    <item>
      <title>Re: Pass two Date Ranges into DAX Formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Pass-two-Date-Ranges-into-DAX-Formula/m-p/3284464#M122079</link>
      <description>&lt;P&gt;This is helpful!&amp;nbsp; May I ask how you named the slicers as in the following statements?&amp;nbsp; Stated another way, not sure how to name my slicers as "BeforeSlicer" and "AfterSlicer".&amp;nbsp; Perhaps as a named variable?&lt;/P&gt;&lt;PRE&gt;Growth % =
var __periodBefore =
	TREATAS(
		VALUES( BeforeSlicer[Date] ),
		'Dates'[Date]
	)
var __periodAfter =
	TREATAS(
		VALUES( AfterSlicer[Date] ),
		'Dates'[Date]&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Jun 2023 20:08:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Pass-two-Date-Ranges-into-DAX-Formula/m-p/3284464#M122079</guid>
      <dc:creator>Quinnie2017</dc:creator>
      <dc:date>2023-06-14T20:08:42Z</dc:date>
    </item>
  </channel>
</rss>

