<?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: Dax Min Calculation for Card returning incorrect value in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Min-Calculation-for-Card-returning-incorrect-value/m-p/4093418#M162439</link>
    <description>&lt;P&gt;Thank you so much. I understand that there is no data for 2023 in the dataset. But the measure is returning data for 2023. And my calculations should have returned the correct results but it is not which is strange. Thank you so much.&lt;/P&gt;</description>
    <pubDate>Sat, 10 Aug 2024 18:42:44 GMT</pubDate>
    <dc:creator>KKVerma</dc:creator>
    <dc:date>2024-08-10T18:42:44Z</dc:date>
    <item>
      <title>Dax Min Calculation for Card returning incorrect value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Min-Calculation-for-Card-returning-incorrect-value/m-p/4078945#M161952</link>
      <description>&lt;P&gt;Hi Team,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to calculate the minimum value to setup the y axis scale. However, it is returning the incorrect value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a measure called delta which returns current year minus last year sales. I am preparing a stacked column chart.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the below card visual, I am calculating the lowest negative(only considering values less than 0) value amonst all years and by looking at the chart. it should return -120 as it is for 2023. but my calculation is returning -80.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Calculation is :&amp;nbsp;&lt;/P&gt;&lt;D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V&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;ADDCOLUMNS&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;SUMMARIZE&lt;/SPAN&gt;&lt;SPAN&gt; ( &lt;/SPAN&gt;&lt;SPAN&gt;ALLSELECTED&lt;/SPAN&gt;&lt;SPAN&gt;( FctTable ), DimDate[year], DimProd[product] ),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;"@TestAmount"&lt;/SPAN&gt;&lt;SPAN&gt;, [Delta] )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [@TestAmount] &amp;lt; &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&lt;SPAN&gt; _result =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;GROUPBY&lt;/SPAN&gt;&lt;SPAN&gt; ( _Test, DimDate[Year], &lt;/SPAN&gt;&lt;SPAN&gt;"@NegativeCalc"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;SUMX&lt;/SPAN&gt;&lt;SPAN&gt; ( &lt;/SPAN&gt;&lt;SPAN&gt;CURRENTGROUP&lt;/SPAN&gt;&lt;SPAN&gt; (), [@TestAmount] ) )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;MINX&lt;/SPAN&gt;&lt;SPAN&gt; ( _result, [@NegativeCalc] )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could I please request you all to help me debug this issue?&lt;/P&gt;&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="119281" data-lia-user-login="dax" class="lia-mention lia-mention-user"&gt;dax&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Aug 2024 19:55:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Min-Calculation-for-Card-returning-incorrect-value/m-p/4078945#M161952</guid>
      <dc:creator>KKVerma</dc:creator>
      <dc:date>2024-08-04T19:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: Dax Min Calculation for Card returning incorrect value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Min-Calculation-for-Card-returning-incorrect-value/m-p/4078959#M161954</link>
      <description>&lt;LI-CODE lang="markup"&gt;I am trying to calculate the minimum value to setup the y axis scale.&lt;/LI-CODE&gt;
&lt;P&gt;Can you please explain this a bit more?&amp;nbsp; General guidance is to start the y axis at zero, to avoid misrepresenting the data.&lt;/P&gt;</description>
      <pubDate>Sun, 04 Aug 2024 20:12:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Min-Calculation-for-Card-returning-incorrect-value/m-p/4078959#M161954</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-08-04T20:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: Dax Min Calculation for Card returning incorrect value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Min-Calculation-for-Card-returning-incorrect-value/m-p/4082431#M162055</link>
      <description>&lt;P&gt;Basically from the visual, I want to calculate for which year the lowest negative value is there. In my case in the visual I want to consider only values which are negative in visual representation of stacked bar chart. Therefore, the measure should return the total value for 2023 but it's returning incorrect value.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2024 21:34:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Min-Calculation-for-Card-returning-incorrect-value/m-p/4082431#M162055</guid>
      <dc:creator>KKVerma</dc:creator>
      <dc:date>2024-08-05T21:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: Dax Min Calculation for Card returning incorrect value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Min-Calculation-for-Card-returning-incorrect-value/m-p/4086115#M162176</link>
      <description>&lt;P&gt;@lbendlin&amp;nbsp;, thanks for your concern about this case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="777089" data-lia-user-login="KKVerma" class="lia-mention lia-mention-user"&gt;KKVerma&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used the example data you gave and got the expected result. Please check if there is anything that can be improved.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;The modified measure is as follows:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;MINIMUMCALC =
VAR _Test =
    //FILTER (
    //ADDCOLUMNS(
    //SUMMARIZE ( ALLSELECTED( FactTable ),DimDate[year], DimProd[Product] ),
    //"@TestAmount", [Measure])
    //,
    //[@TestAmount] &amp;lt; 0
    //)
    VAR _year =
        SUMMARIZE ( 'DimDate', 'DimDate'[Year] )
    VAR _product =
        SUMMARIZE ( 'DimProd', 'DimProd'[Product] )
    RETURN
        FILTER (
            ADDCOLUMNS (
                FILTER (
                    CROSSJOIN ( _year, _product ),
                    'DimProd'[Product] IN SELECTCOLUMNS ( 'FactTable', 'FactTable'[Product] )
                ),
                "@TestAmount", 'DimDate'[Delta]
            ),
            [@TestAmount] &amp;lt; 0
        )
VAR _result =
    GROUPBY (
        _Test,
        DimDate[Year],
        "@NegativeCalc", SUMX ( CURRENTGROUP (), [@TestAmount] )
    )
RETURN
    MINX ( _result, [@NegativeCalc] )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since the example is missing 2023 for product A in the data, the commented out code yields the following table which don’t have amount of -120:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So we choose to use the CROSSJOIN function to get the combination of product and year. The modified MINIMUMCALC then returns a minimum value of -120:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Zhu&lt;BR /&gt;Community Support Team&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is any 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;&amp;nbsp;to help the other members find it more quickly.&lt;BR /&gt;If I misunderstand your needs or you still have problems on it, please feel free to let us know.&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Thanks a lot!&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2024 07:16:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Min-Calculation-for-Card-returning-incorrect-value/m-p/4086115#M162176</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-07T07:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: Dax Min Calculation for Card returning incorrect value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Min-Calculation-for-Card-returning-incorrect-value/m-p/4093418#M162439</link>
      <description>&lt;P&gt;Thank you so much. I understand that there is no data for 2023 in the dataset. But the measure is returning data for 2023. And my calculations should have returned the correct results but it is not which is strange. Thank you so much.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Aug 2024 18:42:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Min-Calculation-for-Card-returning-incorrect-value/m-p/4093418#M162439</guid>
      <dc:creator>KKVerma</dc:creator>
      <dc:date>2024-08-10T18:42:44Z</dc:date>
    </item>
  </channel>
</rss>

