<?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: random sampling in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/random-sampling/m-p/972315#M11652</link>
    <description>&lt;P&gt;thanks for the reply , but not working unfortunately.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 13 Mar 2020 12:05:39 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-03-13T12:05:39Z</dc:date>
    <item>
      <title>random sampling</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/random-sampling/m-p/972127#M11647</link>
      <description>&lt;LI-SPOILER&gt;&amp;nbsp;&lt;/LI-SPOILER&gt;&lt;P&gt;How to take number of rows as input and show random set of rows ?&lt;/P&gt;&lt;P class="ics-element-donot-delete 1001_CC@"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 10:21:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/random-sampling/m-p/972127#M11647</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-13T10:21:25Z</dc:date>
    </item>
    <item>
      <title>Re: random sampling</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/random-sampling/m-p/972279#M11649</link>
      <description>&lt;P&gt;check it out here&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Desktop/DAX-random-sample/td-p/386571" target="_blank"&gt;https://community.powerbi.com/t5/Desktop/DAX-random-sample/td-p/386571&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Random Selection =&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;VAR SampleSize = 10 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;VAR TableWithRand = ADDCOLUMNS ( OriginalTable, "Rand", RAND () )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;RETURN TOPN ( SampleSize, TableWithRand, [Rand] )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks &amp;amp; regards,&lt;BR /&gt;Pravin Wattamwar&lt;BR /&gt;&lt;A href="http://www.linkedin.com/in/pravin-p-wattamwar" target="_blank"&gt;www.linkedin.com/in/pravin-p-wattamwar&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;If I resolve your problem Mark it as a solution and give kudos.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 11:49:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/random-sampling/m-p/972279#M11649</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-13T11:49:20Z</dc:date>
    </item>
    <item>
      <title>Re: random sampling</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/random-sampling/m-p/972288#M11650</link>
      <description>&lt;P&gt;how to take row count from users?&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 11:53:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/random-sampling/m-p/972288#M11650</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-13T11:53:17Z</dc:date>
    </item>
    <item>
      <title>Re: random sampling</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/random-sampling/m-p/972299#M11651</link>
      <description>&lt;P&gt;Create one table generateseries(1,1000)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then add it in slicer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Allow user to select number of samples&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and undate it in above formula .&lt;/P&gt;&lt;P&gt;in var section add selectedvalue(table[series]) instead of 10.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; regards,&lt;BR /&gt;Pravin Wattamwar&lt;BR /&gt;&lt;A href="http://www.linkedin.com/in/pravin-p-wattamwar" target="_blank"&gt;www.linkedin.com/in/pravin-p-wattamwar&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;If I resolve your problem Mark it as a solution and give kudos.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 11:56:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/random-sampling/m-p/972299#M11651</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-13T11:56:45Z</dc:date>
    </item>
    <item>
      <title>Re: random sampling</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/random-sampling/m-p/972315#M11652</link>
      <description>&lt;P&gt;thanks for the reply , but not working unfortunately.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 12:05:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/random-sampling/m-p/972315#M11652</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-13T12:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: random sampling</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/random-sampling/m-p/972528#M11655</link>
      <description>&lt;P&gt;sorry my bad.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can take user input here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Because columns/tables are can not be dynamic.&lt;/P&gt;&lt;P&gt;They will get loaded at first load only.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the formula will work for static values only not for dynamic values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; regards,&lt;BR /&gt;Pravin Wattamwar&lt;BR /&gt;&lt;A href="http://www.linkedin.com/in/pravin-p-wattamwar" target="_blank"&gt;www.linkedin.com/in/pravin-p-wattamwar&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;If I resolve your problem Mark it as a solution and give kudos.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 12:59:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/random-sampling/m-p/972528#M11655</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-13T12:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: random sampling</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/random-sampling/m-p/972927#M11659</link>
      <description>Of course, you can do that. Don't pay attention to those who say it's not possible. I know It IS possible. I'll have a think about it later today since right now I don't have time to create the solution.&lt;BR /&gt;&lt;BR /&gt;Best&lt;BR /&gt;D</description>
      <pubDate>Fri, 13 Mar 2020 14:18:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/random-sampling/m-p/972927#M11659</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-13T14:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: random sampling</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/random-sampling/m-p/973912#M11695</link>
      <description>&lt;P&gt;Hi there. I'll give you an idea about how to do this. This is probably the only way to do it with the current version of DAX and Power BI.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, let's say you have a table (call it 'Data') in the model with N rows which are numbered consecutively, say, from 0 to (N-1) (the column is called Index). Now, you'll construct a table ('Samples') with these properties:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The first column will hold numbers from 1 to K (there'll be many rows for each value).&lt;/LI&gt;
&lt;LI&gt;The second column will hold the indexes of rows that will be selected for a particular k and SampleId.&lt;/LI&gt;
&lt;LI&gt;The third column will hold the SampleId.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Here's the structure:&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 100%;" border="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD style="width: 33.3333%;"&gt;k&lt;/TD&gt;
&lt;TD style="width: 33.3333%;"&gt;Index&lt;/TD&gt;
&lt;TD style="width: 33.3333%;"&gt;SampleId&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD style="width: 33.3333%;"&gt;1&lt;/TD&gt;
&lt;TD style="width: 33.3333%;"&gt;2&lt;/TD&gt;
&lt;TD style="width: 33.3333%;"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD style="width: 33.3333%;"&gt;1&lt;/TD&gt;
&lt;TD style="width: 33.3333%;"&gt;4&lt;/TD&gt;
&lt;TD style="width: 33.3333%;"&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD style="width: 33.3333%;"&gt;1&lt;/TD&gt;
&lt;TD style="width: 33.3333%;"&gt;9&lt;/TD&gt;
&lt;TD style="width: 33.3333%;"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD style="width: 33.3333%;"&gt;2&lt;/TD&gt;
&lt;TD style="width: 33.3333%;"&gt;1&lt;/TD&gt;
&lt;TD style="width: 33.3333%;"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD style="width: 33.3333%;"&gt;2&lt;/TD&gt;
&lt;TD style="width: 33.3333%;"&gt;6&lt;/TD&gt;
&lt;TD style="width: 33.3333%;"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD style="width: 33.3333%;"&gt;2&lt;/TD&gt;
&lt;TD style="width: 33.3333%;"&gt;8&lt;/TD&gt;
&lt;TD style="width: 33.3333%;"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD style="width: 33.3333%;"&gt;2&lt;/TD&gt;
&lt;TD style="width: 33.3333%;"&gt;3&lt;/TD&gt;
&lt;TD style="width: 33.3333%;"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD style="width: 33.3333%;"&gt;3&lt;/TD&gt;
&lt;TD style="width: 33.3333%;"&gt;4&lt;/TD&gt;
&lt;TD style="width: 33.3333%;"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD style="width: 33.3333%;"&gt;3&lt;/TD&gt;
&lt;TD style="width: 33.3333%;"&gt;2&lt;/TD&gt;
&lt;TD style="width: 33.3333%;"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD style="width: 33.3333%;"&gt;3&lt;/TD&gt;
&lt;TD style="width: 33.3333%;"&gt;8&lt;/TD&gt;
&lt;TD style="width: 33.3333%;"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you see what's going on here? The k column will be sitting on one slicer, the SampleId on another. When you select a value of k, the other slicer will adjust the SampleId from 1 to the number of samples for that particular k. Now you just have to select a sample from the range slicer. This is how you'll obtain a (pseudo-)random selection of rows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For each k you have to create samples where each sample will be a unique combination of the indexes of the rows to select. For k = 1, you only need N samples to cover all possibilities. For k = 2, you need N*(N-1)/2 combinations, for k = 3, you need C(N, k) combinations... but this number of samples will be going up quickly as k increases. So, when k is relatively big you don't need to cover all combinations. Just pick enough of them. Once you have the above table, you can write a measure [Select Row] that will return 1 if the row should be selected and 0 if not. Here it is:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[Select Row] =
var __k = SELECTEDVALUE( 'Samples'[K] )
var __oneSampleSelected = HASONEVALUE( 'Samples'[SampleId] )
var __currentRowid = SELECTEDVALUE( 'Data'[Index] )
var __selectRow =
	__currentRowid in VALUES( 'Samples'[Index] )
return
	if( __oneSampleSelected, 1 * __selectRow )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The visual in which you've placed the rows of the Data table should have a filter on it so that a row will display when [Select Row] is 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;
&lt;P&gt;D&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 19:59:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/random-sampling/m-p/973912#M11695</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-13T19:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: random sampling</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/random-sampling/m-p/977219#M11840</link>
      <description>&lt;P&gt;Thank you vey miuch ! Will try this and update how it goes&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2020 05:09:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/random-sampling/m-p/977219#M11840</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-17T05:09:00Z</dc:date>
    </item>
  </channel>
</rss>

