<?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 IF Statement on MATRIX returns correct value at top level but lower level is wrong in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-Statement-on-MATRIX-returns-correct-value-at-top-level-but/m-p/4015475#M158227</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to show the posted revenue for a product before and after the invoice is cleared.&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have two value types:&lt;/P&gt;&lt;P&gt;Revenue Accrued: this is what we post prior to receive the invoice to have visibility of the incoming revenue&lt;/P&gt;&lt;P&gt;Revenue Invoice: this is the amount after the invoice is paid.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The rule we apply is that if the "Revenue Invoice" is greater or equal to the "Revenue Accrued" then take the "Revenue Invoice", else take the "Revenue Accrued".&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have created two measures for the InvoiceValue and the AccruedValue as showing below:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Then Created a new measure "Revenue" where the rule I mentioned above is applied.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result is that the total value is correct (picking up the higher value) but at the Value type level it is showing both values.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the Revenue Accrued to be blank or zero.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Similarly, if I select a previous month where the Accrued value is higher, I want only the Revenue Accrued type to show the value under the Revenue column and the "Revenue Invoice" to be zero or blank.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;This is a simple example of a more complex report I am currently working on but the issue I am facing is the same.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate any help to resolve this and any explanation of what is wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance,&lt;/P&gt;&lt;P&gt;George&lt;/P&gt;</description>
    <pubDate>Fri, 28 Jun 2024 11:17:54 GMT</pubDate>
    <dc:creator>GeorgeAiva</dc:creator>
    <dc:date>2024-06-28T11:17:54Z</dc:date>
    <item>
      <title>IF Statement on MATRIX returns correct value at top level but lower level is wrong</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-Statement-on-MATRIX-returns-correct-value-at-top-level-but/m-p/4015475#M158227</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to show the posted revenue for a product before and after the invoice is cleared.&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have two value types:&lt;/P&gt;&lt;P&gt;Revenue Accrued: this is what we post prior to receive the invoice to have visibility of the incoming revenue&lt;/P&gt;&lt;P&gt;Revenue Invoice: this is the amount after the invoice is paid.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The rule we apply is that if the "Revenue Invoice" is greater or equal to the "Revenue Accrued" then take the "Revenue Invoice", else take the "Revenue Accrued".&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have created two measures for the InvoiceValue and the AccruedValue as showing below:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Then Created a new measure "Revenue" where the rule I mentioned above is applied.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result is that the total value is correct (picking up the higher value) but at the Value type level it is showing both values.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the Revenue Accrued to be blank or zero.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Similarly, if I select a previous month where the Accrued value is higher, I want only the Revenue Accrued type to show the value under the Revenue column and the "Revenue Invoice" to be zero or blank.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;This is a simple example of a more complex report I am currently working on but the issue I am facing is the same.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate any help to resolve this and any explanation of what is wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance,&lt;/P&gt;&lt;P&gt;George&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2024 11:17:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-Statement-on-MATRIX-returns-correct-value-at-top-level-but/m-p/4015475#M158227</guid>
      <dc:creator>GeorgeAiva</dc:creator>
      <dc:date>2024-06-28T11:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: IF Statement on MATRIX returns correct value at top level but lower level is wrong</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-Statement-on-MATRIX-returns-correct-value-at-top-level-but/m-p/4016134#M158310</link>
      <description>&lt;P&gt;Remove [Value Type]&amp;nbsp; from the matrix rows.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2024 17:54:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-Statement-on-MATRIX-returns-correct-value-at-top-level-but/m-p/4016134#M158310</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-06-28T17:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: IF Statement on MATRIX returns correct value at top level but lower level is wrong</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-Statement-on-MATRIX-returns-correct-value-at-top-level-but/m-p/4016600#M158344</link>
      <description>&lt;P&gt;Thanks for your reply. I know this is an option but the users want to see the value type. There are more than one products and they want to see if the revenue for each product comes from the invoice or from the accrued value. The table will only show one revenue column and not the "Revenue accrued" or " Revenue invoice".&lt;/P&gt;</description>
      <pubDate>Sat, 29 Jun 2024 12:32:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-Statement-on-MATRIX-returns-correct-value-at-top-level-but/m-p/4016600#M158344</guid>
      <dc:creator>GeorgeAiva</dc:creator>
      <dc:date>2024-06-29T12:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: IF Statement on MATRIX returns correct value at top level but lower level is wrong</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-Statement-on-MATRIX-returns-correct-value-at-top-level-but/m-p/4017295#M158385</link>
      <description>&lt;P&gt;I would find that confusing.&amp;nbsp;I cannot assist you with that ask. I hope someone else can help you further.&lt;/P&gt;</description>
      <pubDate>Sun, 30 Jun 2024 21:10:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-Statement-on-MATRIX-returns-correct-value-at-top-level-but/m-p/4017295#M158385</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-06-30T21:10:29Z</dc:date>
    </item>
    <item>
      <title>Re: IF Statement on MATRIX returns correct value at top level but lower level is wrong</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-Statement-on-MATRIX-returns-correct-value-at-top-level-but/m-p/4018044#M158454</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="767640" data-lia-user-login="GeorgeAiva" class="lia-mention lia-mention-user"&gt;GeorgeAiva&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Based on my testing, please &lt;SPAN&gt;try the following methods again:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1.Create the sample table.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2.Create the new measure to &lt;/SPAN&gt;&lt;SPAN&gt;filter the values.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Revenue = 
var accrued = CALCULATE(SUM(Data[Value]), Data[Value type] = "Revenue Accrued")
var invoice = CALCULATE(SUM(Data[Value]), Data[Value type] ="Revenue Invoice")
var _type = SELECTEDVALUE(Data[Value type])
RETURN
IF(invoice &amp;gt;= accrued &amp;amp;&amp;amp; _type = "Revenue Invoice", invoice, 
    IF(invoice &amp;lt; accrued &amp;amp;&amp;amp; _type = "Revenue Accrued", accrued, 0)
)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;3.&lt;/SPAN&gt;&lt;SPAN&gt;Drag the date column into the slicer visual.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;4.&lt;/SPAN&gt;&lt;SPAN&gt;Drag the measures into the &lt;/SPAN&gt;&lt;SPAN&gt;matrix visual&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;5.The result is shown below.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Wisdom Wu&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2024 07:39:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-Statement-on-MATRIX-returns-correct-value-at-top-level-but/m-p/4018044#M158454</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-07-01T07:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: IF Statement on MATRIX returns correct value at top level but lower level is wrong</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-Statement-on-MATRIX-returns-correct-value-at-top-level-but/m-p/4018185#M158463</link>
      <description>&lt;P&gt;Thank you Anonymous&lt;/a&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works at the "Value type" level. How do I make it show the value at Product level and total?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2024 08:36:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-Statement-on-MATRIX-returns-correct-value-at-top-level-but/m-p/4018185#M158463</guid>
      <dc:creator>GeorgeAiva</dc:creator>
      <dc:date>2024-07-01T08:36:26Z</dc:date>
    </item>
    <item>
      <title>Re: IF Statement on MATRIX returns correct value at top level but lower level is wrong</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-Statement-on-MATRIX-returns-correct-value-at-top-level-but/m-p/4026771#M159019</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="767640" data-lia-user-login="GeorgeAiva" class="lia-mention lia-mention-user"&gt;GeorgeAiva&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Please &lt;SPAN&gt;try the following methods again:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1.Create the &lt;/SPAN&gt;&lt;SPAN&gt;measure to sum value.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Sum of value = SUM('Data'[Value])&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;2.Create the new measure to &lt;/SPAN&gt;&lt;SPAN&gt;calculate the max value.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Max value = 
VAR _product = SELECTEDVALUE('Data'[Product])
var _tab = SUMMARIZE(ALLSELECTED('Data'),'Data'[Product],'Data'[Value type],"@sumofvalue",[Sum of value])
var _maxvalue = MAXX(FILTER(_tab,[Product]=_product),[@sumofvalue])
RETURN  
if(_maxvalue= [Sum of value],[Sum of value],0)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;3.&lt;/SPAN&gt;&lt;SPAN&gt;Drag Create the measure to calculate the Revenue.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Revenue = IF( ISINSCOPE('Data'[Value type]),[Max value],SUMX(GROUPBY('Data','Data'[Product],'Data'[Value type]),[Max value]))&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;4.&lt;/SPAN&gt;&lt;SPAN&gt;Drag the measures into the &lt;/SPAN&gt;&lt;SPAN&gt;matrix visual&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt; &lt;SPAN&gt;The result is shown below.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Wisdom Wu&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jul 2024 09:26:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-Statement-on-MATRIX-returns-correct-value-at-top-level-but/m-p/4026771#M159019</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-07-05T09:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: IF Statement on MATRIX returns correct value at top level but lower level is wrong</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-Statement-on-MATRIX-returns-correct-value-at-top-level-but/m-p/4029589#M159270</link>
      <description>&lt;P&gt;this worked. Thank you so much!!!&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2024 07:29:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-Statement-on-MATRIX-returns-correct-value-at-top-level-but/m-p/4029589#M159270</guid>
      <dc:creator>GeorgeAiva</dc:creator>
      <dc:date>2024-07-08T07:29:31Z</dc:date>
    </item>
  </channel>
</rss>

