<?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: Combined SWITCH and SELECTEDVALUE function not working for sum of multiple measures in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Combined-SWITCH-and-SELECTEDVALUE-function-not-working-for-sum/m-p/2995029#M100887</link>
    <description>&lt;P&gt;Hi!&lt;BR /&gt;Yeah I'm actually not sure why it doesn't work. I'm also thinking it might be that there are several measures that "references" several Line_item_IDs which causes SELECTEDVALUE() to returning blank in those cases. Do the measures show blank when they're "by themselves", i.e. not in that SWITCH()/SELECTED() but for example just as a KPI card as well?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;One potential workaround (but I'm not sure) could be to create these measures as variables before the SWITCH() statement, as variables are calculated before calling any function after return.&lt;BR /&gt;&lt;BR /&gt;So for example:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Reporting Value = 
VAR __CM1 = 
([Revenue] + [CoGS] + [Prod. labor costs]) / 1000
return 
SWITCH( 
[...]
    "Contribution margin I", __CM1,
[...]
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Maybe worth a try.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 30 Dec 2022 15:11:32 GMT</pubDate>
    <dc:creator>TomasAndersson</dc:creator>
    <dc:date>2022-12-30T15:11:32Z</dc:date>
    <item>
      <title>Combined SWITCH and SELECTEDVALUE function not working for sum of multiple measures</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Combined-SWITCH-and-SELECTEDVALUE-function-not-working-for-sum/m-p/2994980#M100883</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to set up a DAX-based table visual for a financial statement - based on financial transactions.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;My current set up is now based on a YouTube guide (&lt;A href="https://www.youtube.com/watch?v=J4317R5BvsA&amp;amp;t=539s" target="_blank" rel="noopener"&gt;https://www.youtube.com/watch?v=J4317R5BvsA&amp;amp;t=539s&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;The major difference between my approach and the one in the YouTube guide is that I'm working on financial transactions rather than aggrecated categories.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far so good, but I'm running into trouble when trying to get values from a measure that sums other measures e.g. a gross margin, which shows a blank.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My measure for retrieving and lining up the correct line item values looks like this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The measures that do work, are all written like this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The measures that don't work, are all written like this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not a super user of Power BI at all, but I suspect that the "sum measures" shows a blank due to the fact that my "sum measures" contain multiple measures. I tried replacing the DAX code with a simple hard typed numbers (e.g. 1000-500-250) formula, which does show up in my table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas for a workaround or a totally different approach is much appreciated.&lt;/P&gt;&lt;P&gt;Happy holidays!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;BR /&gt;Chris&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2022 16:24:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Combined-SWITCH-and-SELECTEDVALUE-function-not-working-for-sum/m-p/2994980#M100883</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-12-30T16:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: Combined SWITCH and SELECTEDVALUE function not working for sum of multiple measures</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Combined-SWITCH-and-SELECTEDVALUE-function-not-working-for-sum/m-p/2995029#M100887</link>
      <description>&lt;P&gt;Hi!&lt;BR /&gt;Yeah I'm actually not sure why it doesn't work. I'm also thinking it might be that there are several measures that "references" several Line_item_IDs which causes SELECTEDVALUE() to returning blank in those cases. Do the measures show blank when they're "by themselves", i.e. not in that SWITCH()/SELECTED() but for example just as a KPI card as well?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;One potential workaround (but I'm not sure) could be to create these measures as variables before the SWITCH() statement, as variables are calculated before calling any function after return.&lt;BR /&gt;&lt;BR /&gt;So for example:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Reporting Value = 
VAR __CM1 = 
([Revenue] + [CoGS] + [Prod. labor costs]) / 1000
return 
SWITCH( 
[...]
    "Contribution margin I", __CM1,
[...]
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Maybe worth a try.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2022 15:11:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Combined-SWITCH-and-SELECTEDVALUE-function-not-working-for-sum/m-p/2995029#M100887</guid>
      <dc:creator>TomasAndersson</dc:creator>
      <dc:date>2022-12-30T15:11:32Z</dc:date>
    </item>
    <item>
      <title>Re: Combined SWITCH and SELECTEDVALUE function not working for sum of multiple measures</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Combined-SWITCH-and-SELECTEDVALUE-function-not-working-for-sum/m-p/2995112#M100893</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;Yes that is a possibility. The engine optimizer might return a blank value and ignores the evaluation&amp;nbsp;of other measures if they came along with a measure that evaluates to a blank.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, it is worth asking whether&amp;nbsp;you have checked if PowerBi has automatically created a relationship between 'Report Structure'[Line_item_ID] and 'Account mapping'[GLA_Line_item_ID] without you noticing that. That is also a possibility.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2022 16:11:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Combined-SWITCH-and-SELECTEDVALUE-function-not-working-for-sum/m-p/2995112#M100893</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-12-30T16:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: Combined SWITCH and SELECTEDVALUE function not working for sum of multiple measures</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Combined-SWITCH-and-SELECTEDVALUE-function-not-working-for-sum/m-p/2995129#M100896</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;&amp;nbsp;you were absolutely right. Deleting the relation fixed it instantly! My boss will be very pleased.&lt;/P&gt;&lt;P&gt;Thanks a lot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actually I created the relationship myself in an earlier rendition.&lt;/P&gt;&lt;P&gt;Could you please explain why the relationship caused the error?&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2022 16:29:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Combined-SWITCH-and-SELECTEDVALUE-function-not-working-for-sum/m-p/2995129#M100896</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-12-30T16:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: Combined SWITCH and SELECTEDVALUE function not working for sum of multiple measures</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Combined-SWITCH-and-SELECTEDVALUE-function-not-working-for-sum/m-p/2995146#M100899</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;It is similar to slicing by&amp;nbsp;&lt;SPAN&gt;'Account mapping'[GLA_Line_item_ID] then using a SWITCH statement on top of it. For sure you'll have EMPTY filter intersections. For example the measure that filters&amp;nbsp;'Account mapping'[GLA_Line_item_ID] = "Revenue" will have a blank value when the line item is not "Revenue" and so on.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2022 16:43:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Combined-SWITCH-and-SELECTEDVALUE-function-not-working-for-sum/m-p/2995146#M100899</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-12-30T16:43:23Z</dc:date>
    </item>
  </channel>
</rss>

