<?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: Creating Batches in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-Batches/m-p/2650662#M78124</link>
    <description>&lt;LI-CODE lang="csharp"&gt;define 

column 
    // First, create manually this column in your table...
    'Statistics'[Helper] = rand()

column 'Statistics'[Index] = 
    // Then this one...
    var currentHelper = 'Statistics'[Helper]
    var Index =
        COUNTROWS(
            filter(
                'Statistics',
                'Statistics'[Helper] &amp;lt;= currentHelper
            )
        )
    return Index

column Statistics[BatchId] = 
    // Then this is going to be the one you need.
    // Hide the other two. Adjust the Batch BatchCount
    // variable.
    var RowCount = COUNTROWS( Statistics )
    var BatchCount = 5
    var Length = int( RowCount / BatchCount  )
    var BatchId = QUOTIENT( Statistics[Index], Length )
    return
        BatchId
        
// TESTING...
EVALUATE
    'Statistics'
order by
    Statistics[BatchId]&lt;/LI-CODE&gt;&lt;P&gt;The above is test code that works in DAX Studio with any table you want (mine was called Statistics). All you have to do is to create the 3 columns (in the order of appearance) in your table. The sad thing is that if you want to do such things in DAX in the most general way, you have to use the random numbers...&lt;/P&gt;</description>
    <pubDate>Wed, 20 Jul 2022 14:05:37 GMT</pubDate>
    <dc:creator>daXtreme</dc:creator>
    <dc:date>2022-07-20T14:05:37Z</dc:date>
    <item>
      <title>Creating Batches</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-Batches/m-p/2650199#M78097</link>
      <description>&lt;P&gt;Hello, need to create a calculated column to label each row item in my table as what batch. So batch 1 is the first 200 row items then batch 2 for the succeeding row items and so on .&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 11:18:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-Batches/m-p/2650199#M78097</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-07-20T11:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Batches</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-Batches/m-p/2650321#M78102</link>
      <description>&lt;P&gt;Please use Power Query for this, not DAX. But to give you the exact solution... we need data to work with. To be able to do it in DAX, your table would have to have a field to sort it on. This is definitely a job for PQ.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 12:10:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-Batches/m-p/2650321#M78102</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-07-20T12:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Batches</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-Batches/m-p/2650330#M78103</link>
      <description>&lt;P&gt;Hello, much as i want to use power query for this, it is a calculated table created in dax hence i will need a dax calculated column. so basically i just need to create a index that will change for every 200 row items. thanks&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 12:13:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-Batches/m-p/2650330#M78103</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-07-20T12:13:58Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Batches</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-Batches/m-p/2650393#M78107</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OK... I understand you're not worried about which rows will get which batch number? What kind of columns do you have in the table? Is there one that is unique?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 12:37:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-Batches/m-p/2650393#M78107</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-07-20T12:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Batches</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-Batches/m-p/2650405#M78108</link>
      <description>&lt;P&gt;Yes you are right i just need to divide the entire table into batches. currently i have 856 rows, so will need to put them in 5 batches. Unfortunately i do not have columns that have unique values&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 12:42:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-Batches/m-p/2650405#M78108</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-07-20T12:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Batches</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-Batches/m-p/2650662#M78124</link>
      <description>&lt;LI-CODE lang="csharp"&gt;define 

column 
    // First, create manually this column in your table...
    'Statistics'[Helper] = rand()

column 'Statistics'[Index] = 
    // Then this one...
    var currentHelper = 'Statistics'[Helper]
    var Index =
        COUNTROWS(
            filter(
                'Statistics',
                'Statistics'[Helper] &amp;lt;= currentHelper
            )
        )
    return Index

column Statistics[BatchId] = 
    // Then this is going to be the one you need.
    // Hide the other two. Adjust the Batch BatchCount
    // variable.
    var RowCount = COUNTROWS( Statistics )
    var BatchCount = 5
    var Length = int( RowCount / BatchCount  )
    var BatchId = QUOTIENT( Statistics[Index], Length )
    return
        BatchId
        
// TESTING...
EVALUATE
    'Statistics'
order by
    Statistics[BatchId]&lt;/LI-CODE&gt;&lt;P&gt;The above is test code that works in DAX Studio with any table you want (mine was called Statistics). All you have to do is to create the 3 columns (in the order of appearance) in your table. The sad thing is that if you want to do such things in DAX in the most general way, you have to use the random numbers...&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 14:05:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-Batches/m-p/2650662#M78124</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-07-20T14:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Batches</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-Batches/m-p/2650723#M78129</link>
      <description>&lt;P&gt;This is nice! just some few clarification:&lt;/P&gt;&lt;P&gt;1 the first column basically creates a unique value for each row right?&lt;/P&gt;&lt;P&gt;2. what if i already have a unique column but is it is not a number, how will i be able to cummulatively count the rows?&lt;BR /&gt;3. If i already have a define length, let's say 200 i can already proceed with&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ar BatchId = QUOTIENT( Statistics[Index], Length )&lt;/PRE&gt;&lt;P&gt;to assign value of length to 200 right?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 14:31:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-Batches/m-p/2650723#M78129</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-07-20T14:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Batches</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-Batches/m-p/2652309#M78238</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Yes. But it's possible with rand(), even though highly improbable, that you could get 2 same values. But that should not matter much...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. If you have a unique column and its values are comparable (even strings are), then you can use it instead of the one with rand(). The logic is exactly the same.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. Yes, instead of defining how many batches you want, you can directly specify how long a batch&lt;/P&gt;&lt;P&gt;should be. Then, you don't have to calculate the length of the batch and the formula above is correct.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 08:27:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-Batches/m-p/2652309#M78238</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-07-21T08:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Batches</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-Batches/m-p/2654899#M78414</link>
      <description>&lt;P&gt;Ok one last thing if ever i want to put this in a measure what will the changes to be made?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2022 06:46:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-Batches/m-p/2654899#M78414</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-07-22T06:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Batches</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-Batches/m-p/2659020#M78761</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Don't ever put this in a measure because it relies on RANDOM NUMBERS. This means every time you run it, rows can be assigned a different batch id... and unless you're OK with that (are you?), you should not use it as a measure.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2022 11:34:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-Batches/m-p/2659020#M78761</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-07-25T11:34:09Z</dc:date>
    </item>
  </channel>
</rss>

