<?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: DAX Code not working in PBI Desktop in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Code-not-working-in-PBI-Desktop/m-p/2758169#M85380</link>
    <description>&lt;P&gt;This is a &lt;STRONG&gt;QUERY&lt;/STRONG&gt;, not something you can put in PBI just like that. If you want to create a column in a table, then you should extract the pieces that can be used in a calculated column. Certainly, you &lt;STRONG&gt;CANNOT DEFINE&lt;/STRONG&gt; anything in a calc column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Sep 2022 12:24:29 GMT</pubDate>
    <dc:creator>daXtreme</dc:creator>
    <dc:date>2022-09-09T12:24:29Z</dc:date>
    <item>
      <title>DAX Code not working in PBI Desktop</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Code-not-working-in-PBI-Desktop/m-p/2758108#M85375</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to add 5 working days to a date I already have in my Sales table. To achieve this i have followed the steps described in this video:&amp;nbsp;&lt;A href="https://www.youtube.com/watch?v=2HkBbqxBzF0" target="_blank"&gt;https://www.youtube.com/watch?v=2HkBbqxBzF0&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;He describes 2 options the first one works but he explains that the second is better performance wise. So I followed the second one and it gives me the code below which works great in the Dax Studio but when I move the code to the Power BI Desktop file it doesnt.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So how should I change this code so that it works in a new calculated column in the Power bi Desktop?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;DEFINE COLUMN 'Date'[WDN] = 
	VAR WorkingDates = 
		CALCULATETABLE(
			Values ( 'Date'[Date]),
			REMOVEFILTERS ( 'Date'),
			'Date'[Working Day] = TRUE
			)
	VAR Result = 
		RANKX ( WorkingDates, 'Date'[Date], , ASC ) - NOT ('Date'[Working Day])
	RETURN
		Result
	COLUMN 'Sales'[WDN+5] =
		VAR CurrentWDN = RELATED( 'Date'[WDN] )
		VAR CurrentPlus5 = CurrentWDN + 5
		VAR Result =
			LOOKUPVALUE(
			'Date'[Date],
			'Date'[WDN], CurrentPlus5,
			'Date'[Working Day], TRUE
			)
		RETURN
			Result
EVALUATE
	ALL ( 'Sales'[Period.Date Value], 'Sales'[WDN+5])
ORDER BY 'Sales'[Period.Date Value]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2022 12:01:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Code-not-working-in-PBI-Desktop/m-p/2758108#M85375</guid>
      <dc:creator>Gerald23</dc:creator>
      <dc:date>2022-09-09T12:01:44Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Code not working in PBI Desktop</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Code-not-working-in-PBI-Desktop/m-p/2758169#M85380</link>
      <description>&lt;P&gt;This is a &lt;STRONG&gt;QUERY&lt;/STRONG&gt;, not something you can put in PBI just like that. If you want to create a column in a table, then you should extract the pieces that can be used in a calculated column. Certainly, you &lt;STRONG&gt;CANNOT DEFINE&lt;/STRONG&gt; anything in a calc column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2022 12:24:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Code-not-working-in-PBI-Desktop/m-p/2758169#M85380</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-09-09T12:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Code not working in PBI Desktop</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Code-not-working-in-PBI-Desktop/m-p/2767399#M86007</link>
      <description>&lt;P&gt;So I was able to solve this by splitting the code so that it would make two new calculated columns instead of just one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First i created a column called WDN using the code below&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;WDN = 
	VAR WorkingDates = 
		CALCULATETABLE(
			Values ( 'Date'[Date]),
			REMOVEFILTERS ( 'Date'),
			'Date'[Working Day] = TRUE
			)
	VAR Result = 
		RANKX ( WorkingDates, 'Date'[Date], , ASC ) - NOT ('Date'[Working Day])
	RETURN
		Result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then i added another calculated column called WDN+5 using this code&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;WDN+5 = 
		VAR CurrentWDN =  'Date'[WDN]
		VAR CurrentPlus5 = CurrentWDN + 5
		VAR Result =
			LOOKUPVALUE(
			'Date'[Date],
			'Date'[WDN], CurrentPlus5,
			'Date'[Working Day], TRUE
			)
		RETURN
			Result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I can use this field in filtering to get the results that are needed for my report.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 13:21:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Code-not-working-in-PBI-Desktop/m-p/2767399#M86007</guid>
      <dc:creator>Gerald23</dc:creator>
      <dc:date>2022-09-14T13:21:11Z</dc:date>
    </item>
  </channel>
</rss>

