<?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: Recursively count items using slicer values in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursively-count-items-using-slicer-values/m-p/3129778#M111301</link>
    <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;Hope this is what you mean&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Count = 
VAR SelectedItems = COUNTROWS ( VALUES ( 'Item'[ItemID] ) )
VAR ItemCountCheck = 
    SUMX ( 
        VALUES ( 'Item'[ItemID] ),
        COUNTROWS ( 
            FILTER ( 
                CALCULATETABLE ( CustomerItem, ALL ( CustomerItem[ID] ) ),
                CustomerItem[ID] = 'Item'[ItemID]
            )
        )
    )
VAR ItemCount = 
    SUMX ( 
        VALUES ( 'Item'[ItemID] ),
        COUNTROWS ( 
            FILTER ( 
                CustomerItem,
                CustomerItem[ID] = 'Item'[ItemID]
            )
        )
    )
RETURN 
    IF ( 
        SelectedItems &amp;gt; 1,
        IF ( 
            ItemCountCheck &amp;gt; 1, 
            ItemCount
        ),
        ItemCount
    )&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 14 Mar 2023 04:46:04 GMT</pubDate>
    <dc:creator>tamerj1</dc:creator>
    <dc:date>2023-03-14T04:46:04Z</dc:date>
    <item>
      <title>Recursively count items using slicer values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursively-count-items-using-slicer-values/m-p/3124599#M110941</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I have a disconnected table :&lt;/P&gt;&lt;P&gt;Items : ItemName&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And a fact table :&lt;/P&gt;&lt;P&gt;CustomerItems : ItemName, CustomerName&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to filter the fact table in a recursive way i.e. if the user selects in the slicer 1 item&amp;nbsp; - this is easy to filter the fact with TREAT AS.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the user select 2 items from the slicer - I need to count the customers from CustomerItems[CustomerName]&amp;nbsp; by first applying the filer from the the first item in the slicer followed by the second item.&amp;nbsp;&amp;nbsp; i.e. the first set will provide set 1 but the second item should filter this set 1 rather than the original fact.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Assume there is 4 maxium selection from the slicer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't think this is possible without using seperate virtual tables but the user may click on 2 items from slicer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any tips how to build that measure?&amp;nbsp;&amp;nbsp; I'm not welded to using a slicer to capture Items.&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, 10 Mar 2023 16:42:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursively-count-items-using-slicer-values/m-p/3124599#M110941</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-03-10T16:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: Recursively count items using slicer values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursively-count-items-using-slicer-values/m-p/3125217#M110989</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt; , it you need &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Item 1, count(Customer)&lt;/P&gt;
&lt;P&gt;item2 , count(Customer)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then it is simple distinctcount(Table[Customer])&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if you need liek&lt;/P&gt;
&lt;P&gt;Item 1&amp;nbsp; - Count&lt;/P&gt;
&lt;P&gt;Item 1, Item 2&amp;nbsp; - Count&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then consider window function in distinctcount(Table[Customer])&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;calculate( distinctcount(Table[Customer]) , window(1,abs,0.rel, allselected(Table[item]) ,ORDERBY(Table[item])))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: &lt;A href="https://youtu.be/nxc_IWl-tTc" target="_blank"&gt;https://youtu.be/nxc_IWl-tTc&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Mar 2023 01:40:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursively-count-items-using-slicer-values/m-p/3125217#M110989</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2023-03-11T01:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: Recursively count items using slicer values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursively-count-items-using-slicer-values/m-p/3125289#M110994</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;Please provide more details along with an example&lt;/P&gt;</description>
      <pubDate>Sat, 11 Mar 2023 04:08:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursively-count-items-using-slicer-values/m-p/3125289#M110994</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-03-11T04:08:21Z</dc:date>
    </item>
    <item>
      <title>Re: Recursively count items using slicer values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursively-count-items-using-slicer-values/m-p/3127925#M111185</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In Item table we have&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ItemID&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;5&lt;/P&gt;&lt;P&gt;6&lt;/P&gt;&lt;P&gt;7&lt;/P&gt;&lt;P&gt;8&lt;/P&gt;&lt;P&gt;9&lt;/P&gt;&lt;P&gt;10&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In CustomerItem&amp;nbsp; Table we have&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CustomerID&amp;nbsp; &amp;nbsp; &amp;nbsp;ItemID&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So when user selects item 1 in the slicer the count is 3 customers and we need the display customers below,&lt;/P&gt;&lt;P&gt;Customer ID&amp;nbsp; &amp;nbsp; Item ID&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When the user adds to to the selection i.e. item 1 and item 2&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We need to re-calcuate using the customer ID's found from the first calculation ie. 1, 2, 3 and re-calculate the count / filter based on item 2&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i.e.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Customer ID&amp;nbsp; &amp;nbsp; ItemID&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Customer Count is now 2&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure if we can do this recursive calculation with Window functions unless I duplicate the fact for each item selectable which isn't really an option as this data in CustomerItem&amp;nbsp; is rougly 50m rows&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Nelly&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2023 13:10:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursively-count-items-using-slicer-values/m-p/3127925#M111185</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-03-13T13:10:46Z</dc:date>
    </item>
    <item>
      <title>Re: Recursively count items using slicer values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursively-count-items-using-slicer-values/m-p/3128002#M111189</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;Does it have to be a disconnected table?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2023 12:49:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursively-count-items-using-slicer-values/m-p/3128002#M111189</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-03-13T12:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: Recursively count items using slicer values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursively-count-items-using-slicer-values/m-p/3128040#M111191</link>
      <description>&lt;P&gt;Nope - I can remodel that aspect if needed&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2023 13:04:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursively-count-items-using-slicer-values/m-p/3128040#M111191</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-03-13T13:04:50Z</dc:date>
    </item>
    <item>
      <title>Re: Recursively count items using slicer values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursively-count-items-using-slicer-values/m-p/3128152#M111199</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;This is based on a disconnected table&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Count = 
VAR SelectedItems = COUNTROWS ( VALUES ( 'Item'[ItemID] ) )
VAR ItemCount = 
    SUMX ( 
        VALUES ( 'Item'[ItemID] ),
        COUNTROWS ( 
            FILTER ( 
                CustomerItem,
                CustomerItem[ID] = 'Item'[ItemID]
            )
        )
    )
RETURN 
    IF ( 
        SelectedItems &amp;gt; 1,
        IF ( 
            ItemCount &amp;gt; 1, 
            ItemCount
        ),
        ItemCount
    )&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 13 Mar 2023 13:46:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursively-count-items-using-slicer-values/m-p/3128152#M111199</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-03-13T13:46:45Z</dc:date>
    </item>
    <item>
      <title>Re: Recursively count items using slicer values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursively-count-items-using-slicer-values/m-p/3128456#M111211</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I need to add the Item ID to the table visual too - this breaks the measure unfortunately.&amp;nbsp; &amp;nbsp;Any ideas how I can amend the measure to display Item ID in the visual along with Customer ID?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2023 15:17:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursively-count-items-using-slicer-values/m-p/3128456#M111211</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-03-13T15:17:33Z</dc:date>
    </item>
    <item>
      <title>Re: Recursively count items using slicer values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursively-count-items-using-slicer-values/m-p/3128467#M111213</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;Please provide sample of the expected results&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2023 15:21:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursively-count-items-using-slicer-values/m-p/3128467#M111213</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-03-13T15:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: Recursively count items using slicer values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursively-count-items-using-slicer-values/m-p/3129778#M111301</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;Hope this is what you mean&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Count = 
VAR SelectedItems = COUNTROWS ( VALUES ( 'Item'[ItemID] ) )
VAR ItemCountCheck = 
    SUMX ( 
        VALUES ( 'Item'[ItemID] ),
        COUNTROWS ( 
            FILTER ( 
                CALCULATETABLE ( CustomerItem, ALL ( CustomerItem[ID] ) ),
                CustomerItem[ID] = 'Item'[ItemID]
            )
        )
    )
VAR ItemCount = 
    SUMX ( 
        VALUES ( 'Item'[ItemID] ),
        COUNTROWS ( 
            FILTER ( 
                CustomerItem,
                CustomerItem[ID] = 'Item'[ItemID]
            )
        )
    )
RETURN 
    IF ( 
        SelectedItems &amp;gt; 1,
        IF ( 
            ItemCountCheck &amp;gt; 1, 
            ItemCount
        ),
        ItemCount
    )&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 14 Mar 2023 04:46:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursively-count-items-using-slicer-values/m-p/3129778#M111301</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-03-14T04:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: Recursively count items using slicer values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursively-count-items-using-slicer-values/m-p/3131012#M111415</link>
      <description>&lt;P&gt;Is it possible to amend this calculation to use in a card visual that returns the distinct count of customerID identified in the last measure?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 14:25:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursively-count-items-using-slicer-values/m-p/3131012#M111415</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-03-14T14:25:14Z</dc:date>
    </item>
    <item>
      <title>Re: Recursively count items using slicer values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursively-count-items-using-slicer-values/m-p/3132501#M111510</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;I have to create the relationship. Should it be something like this?&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 04:47:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursively-count-items-using-slicer-values/m-p/3132501#M111510</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-03-15T04:47:27Z</dc:date>
    </item>
  </channel>
</rss>

