<?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: Multiply a measure with factor from related table in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Multiply-a-measure-with-factor-from-related-table/m-p/960381#M11196</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;// Basic measure - can be hidden
// However, hidden measures should start with _
// like: [_Balance] to mark them explicitly
// they are private. I think this measure
// should be private and named differently
// because technically it's not a balance
// unless you calculate this sum for
// periods of time that start with the very
// first day you have in your Date table.
// Otherwise, it's just a sum of transactions
// on the account, not a balance.
[Balance] = SUM( Fact[Amount] )

// Your Date table should have a column
// that for each day holds the 1st day
// of the week to which the date belongs.

// Balance @ [S]tart [o]f [Latest] [W]eek works for
// any selected period of time and returns
// the balance for the first day of the
// most recent visible week.
[Balance @ SoLW] =
var __startOfWeek = MAX( 'Date'[FirstDayOfWeek] )
var __result =
	calculate(
		[Balance],
		'Date'[Date] &amp;lt;= __startOfWeek
	)
return
	__result
	
// Balance shown only when the week visible
// is marked in the Date table as [This Week?]
// C in the abbreviation stands for Current.
[Balance @ SoCW] =
var __isCurrentWeek =
	SELECTEDVALUE( 'Date'[This Week?], FALSE() )
var __balance = [Balance @ SoW]
return
	// This will return BLANK for other weeks
	// but if you want to see 0 for them just
	// add to the whole IF expression 0.
	if( __isCurrentWeek, __balance )
	
	
// Of course, your Date table should contain
// each and every day without gaps.&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 05 Mar 2020 11:30:26 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-03-05T11:30:26Z</dc:date>
    <item>
      <title>Multiply a measure with factor from related table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Multiply-a-measure-with-factor-from-related-table/m-p/960267#M11187</link>
      <description>&lt;P&gt;Very new to DAX and Power BI so there are some aspects I don't fully comprehend yet. Bear with me please...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have my Fact table with&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID; Amount; Type; Transaction Date&lt;/P&gt;&lt;P&gt;1;200;BT;01-02-2020&lt;/P&gt;&lt;P&gt;2;400;BT;05-03-2020&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then of course I have my Date table, simplified:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Date; Year+week code; This week? (true/false); TodayFactor (conditional)&lt;/P&gt;&lt;P&gt;01-02-2020;202005;false;0&lt;/P&gt;&lt;P&gt;05-03-2020;202010;true;1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've created a measure for my Fact table. The intention is to calculate the balance for the Start of The Week. However I only want the value if the week is the current week (= This week? from the Date table). Else I'd simply like 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BT Start of Week =&amp;nbsp;&lt;SPAN&gt;CALCULATE(SUM(Fact[Amount]);FILTER(ALL(Date);Date[Year+week code]&amp;lt;MAX(Date[Year+week code])))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I proceed from here? I've tried multiplying with a factor using SUMX and RELATED, but can't get that going (and I have defined a relationship between the Fact and Date table). Also I've tried using IF-statements with no joy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help please? Much appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 09:56:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Multiply-a-measure-with-factor-from-related-table/m-p/960267#M11187</guid>
      <dc:creator>PeterElbek</dc:creator>
      <dc:date>2020-03-05T09:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: Multiply a measure with factor from related table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Multiply-a-measure-with-factor-from-related-table/m-p/960300#M11192</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="212909" data-lia-user-login="PeterElbek" class="lia-mention lia-mention-user"&gt;PeterElbek&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;CALCULATE(
    SUM( Fact[Amount] );
    FILTER(
        ALL( Date ); 
        Date[Year+week code] = TRUE()
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;Best Regards,&lt;BR /&gt;Mariusz&lt;BR /&gt;&lt;BR /&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;I&gt;Accepting it as the solution&lt;/I&gt;&lt;/STRONG&gt;.&lt;BR /&gt;&lt;BR /&gt;Please feel free to connect with me.&lt;BR /&gt;&lt;A href="https://www.linkedin.com/in/mariusz-repczynski-065a7362/" target="_blank"&gt; LinkedIn &lt;/A&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 10:17:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Multiply-a-measure-with-factor-from-related-table/m-p/960300#M11192</guid>
      <dc:creator>Mariusz</dc:creator>
      <dc:date>2020-03-05T10:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: Multiply a measure with factor from related table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Multiply-a-measure-with-factor-from-related-table/m-p/960381#M11196</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;// Basic measure - can be hidden
// However, hidden measures should start with _
// like: [_Balance] to mark them explicitly
// they are private. I think this measure
// should be private and named differently
// because technically it's not a balance
// unless you calculate this sum for
// periods of time that start with the very
// first day you have in your Date table.
// Otherwise, it's just a sum of transactions
// on the account, not a balance.
[Balance] = SUM( Fact[Amount] )

// Your Date table should have a column
// that for each day holds the 1st day
// of the week to which the date belongs.

// Balance @ [S]tart [o]f [Latest] [W]eek works for
// any selected period of time and returns
// the balance for the first day of the
// most recent visible week.
[Balance @ SoLW] =
var __startOfWeek = MAX( 'Date'[FirstDayOfWeek] )
var __result =
	calculate(
		[Balance],
		'Date'[Date] &amp;lt;= __startOfWeek
	)
return
	__result
	
// Balance shown only when the week visible
// is marked in the Date table as [This Week?]
// C in the abbreviation stands for Current.
[Balance @ SoCW] =
var __isCurrentWeek =
	SELECTEDVALUE( 'Date'[This Week?], FALSE() )
var __balance = [Balance @ SoW]
return
	// This will return BLANK for other weeks
	// but if you want to see 0 for them just
	// add to the whole IF expression 0.
	if( __isCurrentWeek, __balance )
	
	
// Of course, your Date table should contain
// each and every day without gaps.&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 11:30:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Multiply-a-measure-with-factor-from-related-table/m-p/960381#M11196</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-05T11:30:26Z</dc:date>
    </item>
  </channel>
</rss>

