<?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: Need help on classifying value in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-on-classifying-value/m-p/2244876#M53846</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="236559" data-lia-user-login="VoltesDev" class="lia-mention lia-mention-user"&gt;VoltesDev&lt;/a&gt;&amp;nbsp; can you please provide sample data and desired output in table format?&lt;/P&gt;</description>
    <pubDate>Fri, 17 Dec 2021 14:56:37 GMT</pubDate>
    <dc:creator>smpa01</dc:creator>
    <dc:date>2021-12-17T14:56:37Z</dc:date>
    <item>
      <title>Need help on classifying value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-on-classifying-value/m-p/2244303#M53808</link>
      <description>&lt;P&gt;Hello guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need you help on my issue here, that if I have this kind of data :&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;What I need is to calculate the age of the ending qty.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a setup of grouping to classify the age 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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to make a matrix that grouping the end quantity ?&lt;/P&gt;&lt;P&gt;The problem I noticed is I can't just use the Date and using Datediff, if lets say today is April 2021. because it will need to track when it is minus, it should substract the oldest qty first. This is actually for inventory movement transactions which usually we called it First In First Out (FIFO)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I'm talking about:&lt;/P&gt;&lt;P&gt;If just by Sum with its respective date (with Datediff to April 2021), I will get 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;But that is wrong, the correct result should be 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;Both ending (available) qty is same, 12, but we cannot just sum the month of March to be -3, since the minus is supposed to substrat the previous qty which maybe not in the same month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wonder this kind of analysis / calculation can be achieve by DAX ? FYI, the data will also have different items (ItemsA, itemsB, etc) I just want to describe more clear so only use 1 item.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please advice.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Dec 2021 10:19:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-on-classifying-value/m-p/2244303#M53808</guid>
      <dc:creator>VoltesDev</dc:creator>
      <dc:date>2021-12-17T10:19:32Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on classifying value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-on-classifying-value/m-p/2244742#M53838</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="236559" data-lia-user-login="VoltesDev" class="lia-mention lia-mention-user"&gt;VoltesDev&lt;/a&gt; , If this based on today's date you can add a new column &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;New Column =&lt;/P&gt;
&lt;P&gt;var _diff = datediff([Date], today(), Month())&lt;/P&gt;
&lt;P&gt;return&lt;/P&gt;
&lt;P&gt;Switch( True() ,&lt;/P&gt;
&lt;P&gt;_diff &amp;lt;= 1 , " 1 Month",&lt;/P&gt;
&lt;P&gt;_diff &amp;lt;= 2 , " 2 Month",&lt;/P&gt;
&lt;P&gt;"&amp;gt; 2 Month"&lt;/P&gt;
&lt;P&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use this in visual&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In case you need based on the selected date, You need a measure and then you need to use segmentation&lt;/P&gt;
&lt;P&gt;Dynamic Segmentation Bucketing Binning&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-Segmentation-Bucketing-Binning/m-p/1387187#M626" target="_blank"&gt;https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-Segmentation-Bucketing-Binning/m-p/1387187#M626&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Dynamic Segmentation, Bucketing or Binning: &lt;A href="https://youtu.be/CuczXPj0N-k" target="_blank"&gt;https://youtu.be/CuczXPj0N-k&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Dec 2021 13:48:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-on-classifying-value/m-p/2244742#M53838</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2021-12-17T13:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on classifying value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-on-classifying-value/m-p/2244869#M53845</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm sorry, but I believe that only will not work. If I only use the date and calculate DateDiff, it will make the 1st month column -3 like my example. So the expectation is the 2nd matrix 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;Thanks,&lt;/P&gt;</description>
      <pubDate>Fri, 17 Dec 2021 14:53:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-on-classifying-value/m-p/2244869#M53845</guid>
      <dc:creator>VoltesDev</dc:creator>
      <dc:date>2021-12-17T14:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on classifying value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-on-classifying-value/m-p/2244876#M53846</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="236559" data-lia-user-login="VoltesDev" class="lia-mention lia-mention-user"&gt;VoltesDev&lt;/a&gt;&amp;nbsp; can you please provide sample data and desired output in table format?&lt;/P&gt;</description>
      <pubDate>Fri, 17 Dec 2021 14:56:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-on-classifying-value/m-p/2244876#M53846</guid>
      <dc:creator>smpa01</dc:creator>
      <dc:date>2021-12-17T14:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on classifying value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-on-classifying-value/m-p/2244918#M53849</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="24978" data-lia-user-login="smpa01" class="lia-mention lia-mention-user"&gt;smpa01&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm sorry, I hope this is applicable ?&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;Item&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;Qty&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;ItemA&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;9/1/2021&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ItemA&lt;/TD&gt;&lt;TD&gt;10/1/2021&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ItemA&lt;/TD&gt;&lt;TD&gt;11/1/2021&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ItemA&lt;/TD&gt;&lt;TD&gt;11/1/2021&lt;/TD&gt;&lt;TD&gt;-5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ItemB&lt;/TD&gt;&lt;TD&gt;10/1/2021&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ItemC&lt;/TD&gt;&lt;TD&gt;9/1/2021&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ItemC&lt;/TD&gt;&lt;TD&gt;10/1/2021&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ItemC&lt;/TD&gt;&lt;TD&gt;11/1/2021&lt;/TD&gt;&lt;TD&gt;-5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the grouping :&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;Age&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;From&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;To&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1 month&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2 month&lt;/TD&gt;&lt;TD&gt;31&lt;/TD&gt;&lt;TD&gt;60&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;gt; 2 month&lt;/TD&gt;&lt;TD&gt;61&lt;/TD&gt;&lt;TD&gt;9999&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the expectation is 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;Many thanks in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Dec 2021 15:26:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-on-classifying-value/m-p/2244918#M53849</guid>
      <dc:creator>VoltesDev</dc:creator>
      <dc:date>2021-12-17T15:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on classifying value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-on-classifying-value/m-p/2244953#M53854</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="24978" data-lia-user-login="smpa01" class="lia-mention lia-mention-user"&gt;smpa01&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So sorry but I seems cannot get the table right, tried many ways, from copying from excel, insert table from this tools and copy from excel again until I tried to insert table again and key in manually one by one, but it looks terrible after post.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But if I tried to copy back, it is already in table format. I'm not sure what's going on with this editor.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 17 Dec 2021 15:32:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-on-classifying-value/m-p/2244953#M53854</guid>
      <dc:creator>VoltesDev</dc:creator>
      <dc:date>2021-12-17T15:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on classifying value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-on-classifying-value/m-p/2245449#M53891</link>
      <description>&lt;P&gt;I haven't tested this logic carefully, but I think something like this might get you on the right track:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;2 month =
VAR MaxDate   = CALCULATE ( MAX ( Inventory[Date] ), ALL ( Inventory ) )
VAR StartDate = MaxDate - 60 //Days To
VAR EndDate   = MaxDate - 30 //Days From
VAR PriorQty =
    CALCULATE ( SUM ( Inventory[Qty] ), Inventory[Date] &amp;lt;= StartDate )
VAR AddedQty =
    CALCULATE (
        SUM ( Inventory[Qty] ),
        Inventory[Date] &amp;gt; StartDate,
        Inventory[Date] &amp;lt;= EndDate,
        Inventory[Qty] &amp;gt; 0
    )
VAR SubtractedQty =
    - CALCULATE (
        SUM ( Inventory[Qty] ),
        Inventory[Date] &amp;gt; StartDate,
        Inventory[Qty] &amp;lt; 0
    )
RETURN
    IF (
        PriorQty &amp;gt; SubtractedQty,
        AddedQty,
        PriorQty + AddedQty - SubtractedQty
    )&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 17 Dec 2021 22:32:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-on-classifying-value/m-p/2245449#M53891</guid>
      <dc:creator>AlexisOlson</dc:creator>
      <dc:date>2021-12-17T22:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on classifying value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-on-classifying-value/m-p/2248779#M54051</link>
      <description>&lt;P&gt;Hi， &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="236559" data-lia-user-login="VoltesDev" class="lia-mention lia-mention-user"&gt;VoltesDev&lt;/a&gt;&amp;nbsp;；&lt;/P&gt;
&lt;P&gt;Try it.&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;Measure = 
var _1m=CALCULATE(SUM([Qty]),FILTER(ALL('Table'),[Item]=MAX('Table'[Item])&amp;amp;&amp;amp;[month]="1 month"))
var _2m=CALCULATE(SUM([Qty]),FILTER(ALL('Table'),[Item]=MAX('Table'[Item])&amp;amp;&amp;amp;[month]="2 month"))
var _3m=CALCULATE(SUM([Qty]),FILTER(ALL('Table'),[Item]=MAX('Table'[Item])&amp;amp;&amp;amp;[month]="&amp;gt;2 month"))
var   _total=SWITCH( MAX([month]),"1 month",IF(_1m+_2m&amp;gt; 0&amp;amp;&amp;amp;_1m&amp;lt;0,_1m+_2m,0),"2 month",IF(_1m+_2m&amp;lt;0,_1m+_2m+_3m,_2m),"&amp;gt;2 month",IF(_1m&amp;lt;0&amp;amp;&amp;amp;_1m+_2m&amp;gt;0,_3m-_2m,0))
return IF(HASONEVALUE('Table'[month]),_total,SUM('Table'[Qty]))&lt;/LI-CODE&gt;
&lt;P&gt;The final output is shown below:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Community Support Team_ Yalan Wu&lt;BR /&gt;If this post &lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Dec 2021 02:28:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-on-classifying-value/m-p/2248779#M54051</guid>
      <dc:creator>v-yalanwu-msft</dc:creator>
      <dc:date>2021-12-21T02:28:16Z</dc:date>
    </item>
  </channel>
</rss>

