{"id":3970,"date":"2022-01-30T00:32:18","date_gmt":"2022-01-30T08:32:18","guid":{"rendered":"https:\/\/SUMMALAI.COM\/?p=3970"},"modified":"2022-01-30T00:32:21","modified_gmt":"2022-01-30T08:32:21","slug":"how-to-fix-a-function-calculate-has-been-used-in-a-true-false-expression-that-is-used-as-a-table-filter-expression-this-is-not-allowed","status":"publish","type":"post","link":"https:\/\/SUMMALAI.COM\/?p=3970","title":{"rendered":"How to Fix &#8220;A function &#8216;CALCULATE&#8217; has been used in a True\/False expression that is used as a table filter expression. This is not allowed.&#8221;"},"content":{"rendered":"\n<p>Sample problem:<\/p>\n\n\n\n<p>I&#8217;m looking for a more elegant way sum based on a prior business day calculation.&nbsp; The following *does work* but will get a little more cumbersome when doing MTD or YTD calculations:<\/p>\n\n\n\n<p>Prior Day Invoiced = CALCULATE(sum(&#8216;Sales Ledger Transactions'[Net Sales]),&#8217;Sales Ledger Transactions'[Fact Attributes.Source Sale Type Code] = &#8220;INVOICED&#8221;,<br>&#8216;Sales Ledger Transactions'[Date.Date] = (if(weekday(today(),1)=1,today() &#8211; 2,<br>if(WEEKDAY(today(),1)=2,today()-3, today()-1))))<\/p>\n\n\n\n<p>What I&#8217;d like to do (see below) blows up with the error &#8220;<strong>A function &#8216;CALCULATE&#8217; has been used in a True\/False expression that is used as a table filter expression. This is not allowed.<\/strong>&#8220;.\u00a0 This seems pretty simple but I can&#8217;t seem to make it work:<\/p>\n\n\n\n<p>Prior Day Invoiced = CALCULATE(sum(&#8216;Sales Ledger Transactions'[Net Sales]),&#8217;Sales Ledger Transactions'[Fact Attributes.Source Sale Type Code] = &#8220;INVOICED&#8221;, &#8216;Sales Ledger Transactions'[Date.Date] = [Priorbusinessday])<\/p>\n\n\n\n<p>Priorbusinessday = if(weekday(today(),1)=1,today() &#8211; 2, if(WEEKDAY(today(),1)=2,today()-3, today()-1))<\/p>\n\n\n\n<p>Is there a more elegant way to use the Priorbusinessday measure or will I have to use the first method?<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Solutions:<\/p>\n\n\n\n<p>Setting the measure equal to a variable first. Because &#8216;Calculate&#8221; is not accepting a true\/false expression as a filter.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><em>Prior Day Invoiced =\nVAR PreviousBusinessDay = [Priorbusinessday]\nRETURN\n    CALCULATE (\n        SUM ( 'Sales Ledger Transactions'[Net Sales] ),\n        'Sales Ledger Transactions'[Fact Attributes.Source Sale Type Code] = \"INVOICED\",\n        'Sales Ledger Transactions'[Date.Date] = PreviousBusinessDay\n    )<\/em><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sample problem: I&#8217;m looking for a more elegant way sum based on a prior business day calculation.&nbsp; The following *does work* but will get a little more cumbersome when doing MTD or YTD calculations: Prior Day Invoiced = CALCULATE(sum(&#8216;Sales Ledger Transactions'[Net Sales]),&#8217;Sales Ledger Transactions'[Fact Attributes.Source Sale Type Code] = &#8220;INVOICED&#8221;,&#8216;Sales Ledger Transactions'[Date.Date] = (if(weekday(today(),1)=1,today() &#8211; <a class=\"read-more\" href=\"https:\/\/SUMMALAI.COM\/?p=3970\">Read More<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[621],"tags":[1088,1087],"class_list":["post-3970","post","type-post","status-publish","format-standard","hentry","category-power-bi","tag-calculate-has-been-used-in-a-true-false-expression-2","tag-calculate-not-accepting-a-true-false"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/3970","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3970"}],"version-history":[{"count":1,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/3970\/revisions"}],"predecessor-version":[{"id":3971,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/3970\/revisions\/3971"}],"wp:attachment":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3970"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3970"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3970"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}