<?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: get value from table with 2 conditions in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/get-value-from-table-with-2-conditions/m-p/743540#M2389</link>
    <description>&lt;P&gt;&lt;STRONG&gt;Mate, DAX is simple but not easy&amp;nbsp;&lt;/STRONG&gt;- let that sink in. I'll give you good advice: get yourself a good book on DAX and read. The best book by far is "The Ultimate Guide To DAX" by The Italians.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Second, filters in CALCULATE are always tables. Even though you can write&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;T[Col] = "value"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it's always expanded into&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FILTER(&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; ALL ( T[Col] ),&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; T[Col] = "value"&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It means, among others, that you can't use two different columns in such a boolean expression. And this is what you're trying to do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Secondly, don't do this:&amp;nbsp;&lt;SPAN&gt;left(Account[Accounting Class]; 3). Please create a calculated column with this formula in it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thirdly, then you'll be able to do this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Acc 211 =
var __today = [Today formatted]
var __acc211 =
	CALCULATE(
		SUM( 'Account Balance'[Amount] ),
		'Date'[Date ID] = __today,
		Account[Accounting Class 3] = "211" -- this is the new calculated column (hidden)
	)
return
	__acc211&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Easy? That's what I thought :)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Best&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Darek&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Jul 2019 14:42:38 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-07-18T14:42:38Z</dc:date>
    <item>
      <title>get value from table with 2 conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/get-value-from-table-with-2-conditions/m-p/743385#M2377</link>
      <description>&lt;P&gt;Hi all !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have problem with unfriendly DAX :( I need to get this value (written in T-SQL):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select [Amount]&lt;/P&gt;&lt;P&gt;from [Account Balance]&lt;/P&gt;&lt;P&gt;where left(account,3)=211 and date=today()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so I wrote this DAX formula:&lt;/P&gt;&lt;P&gt;Acc211 = calculate(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;sumx(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'Account Balance'; 'Account Balance'[Amount]);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AND(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; left(Account[Accounting Class]; 3) = "211";&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'Date'[Date ID]=[Today formatted]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; )&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;)&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;*Today formatted is TODAY converted on the INT and is OK (validated)&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;I got error message:&amp;nbsp;&lt;BR /&gt;&amp;nbsp;"The expression contains multiple columns, but only a single column can be used in a True/False expression that is used as a table filter expression."&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;can you please help me to fix it, and explain why and where is the mistake?&lt;/P&gt;&lt;P&gt;many thanks !!&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 12:28:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/get-value-from-table-with-2-conditions/m-p/743385#M2377</guid>
      <dc:creator>ph</dc:creator>
      <dc:date>2019-07-18T12:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: get value from table with 2 conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/get-value-from-table-with-2-conditions/m-p/743540#M2389</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Mate, DAX is simple but not easy&amp;nbsp;&lt;/STRONG&gt;- let that sink in. I'll give you good advice: get yourself a good book on DAX and read. The best book by far is "The Ultimate Guide To DAX" by The Italians.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Second, filters in CALCULATE are always tables. Even though you can write&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;T[Col] = "value"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it's always expanded into&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FILTER(&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; ALL ( T[Col] ),&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; T[Col] = "value"&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It means, among others, that you can't use two different columns in such a boolean expression. And this is what you're trying to do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Secondly, don't do this:&amp;nbsp;&lt;SPAN&gt;left(Account[Accounting Class]; 3). Please create a calculated column with this formula in it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thirdly, then you'll be able to do this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Acc 211 =
var __today = [Today formatted]
var __acc211 =
	CALCULATE(
		SUM( 'Account Balance'[Amount] ),
		'Date'[Date ID] = __today,
		Account[Accounting Class 3] = "211" -- this is the new calculated column (hidden)
	)
return
	__acc211&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Easy? That's what I thought :)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Best&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Darek&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 14:42:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/get-value-from-table-with-2-conditions/m-p/743540#M2389</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-18T14:42:38Z</dc:date>
    </item>
    <item>
      <title>Re: get value from table with 2 conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/get-value-from-table-with-2-conditions/m-p/743614#M2400</link>
      <description>&lt;P&gt;Thanks Darek for response :)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) thx for tip, I find only book called '&lt;SPAN&gt;The Definitive Guide to DAX: Business Intelligence with Microsoft Excel, SQL ...' did you mean this? :)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2) Why I should&amp;nbsp; avoid to 'left(Account[Accounting Class]; 3)', I agree that code can be less readable for someone, is it bad I will use it as a measure instead of column?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3) the code works, thanks for it&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; (btw agree that DAX is not simple, but definitively not is simple)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 16:07:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/get-value-from-table-with-2-conditions/m-p/743614#M2400</guid>
      <dc:creator>ph</dc:creator>
      <dc:date>2019-07-18T16:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: get value from table with 2 conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/get-value-from-table-with-2-conditions/m-p/743615#M2401</link>
      <description>&lt;P&gt;*&lt;SPAN&gt;&amp;nbsp;(btw agree that DAX is not easy, and definitively not is simple)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 16:10:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/get-value-from-table-with-2-conditions/m-p/743615#M2401</guid>
      <dc:creator>ph</dc:creator>
      <dc:date>2019-07-18T16:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: get value from table with 2 conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/get-value-from-table-with-2-conditions/m-p/743655#M2404</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="154447" data-lia-user-login="ph" class="lia-mention lia-mention-user"&gt;ph&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Thanks Darek for response :)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) thx for tip, I find only book called '&lt;SPAN&gt;The Definitive Guide to DAX: Business Intelligence with Microsoft Excel, SQL ...' did you mean this? :)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;--&amp;gt; Yes. I'd suggest to get the newest version of it. When you start reading this, it'll open your eyes.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2) Why I should&amp;nbsp; avoid to 'left(Account[Accounting Class]; 3)', I agree that code can be less readable for someone, is it bad I will use it as a measure instead of column?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;--&amp;gt; First, it's ugly. Second, you're doing at query time something that could have been done at process time. This hurts performance. Third, stunts in code are BAD if they can easily be avoided. Fourth, you're not using IT as a measure. You're trying to force the engine to perform an operation on a column. This - as I said - takes precious CPU cycles of the Formula Engine (and this engine is single-threaded!). Writing code is not just about writing code. It's about writing PERFORMANT AND WELL READABLE CODE.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;Best&lt;/P&gt;&lt;P&gt;Darek&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 16:55:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/get-value-from-table-with-2-conditions/m-p/743655#M2404</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-18T16:55:03Z</dc:date>
    </item>
  </channel>
</rss>

