title: Microsoft Power BI DAX - Convert a table with a range of integer values in two columns, into a new table with a row for each value in the range
body: <p>I have a situation in which I am using Microsoft Power BI. I have a source table (called Couriers), with a range of weights (MinWeight to MaxWeight) for any given combination of Courier and Country, along with the Freight value.</p>
  <p><a href="https://i.stack.imgur.com/plXBd.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/plXBd.gif" alt="enter image description here" /></a></p>
  <p>I need to develop a <strong>new TABLE</strong> (called Couriers_FlattenedData) in Power BI , in which, I get a row for each value between the MinWeight and MaxWeight.</p>
  <p><a href="https://i.stack.imgur.com/z5fx1.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/z5fx1.gif" alt="enter image description here" /></a></p>
  <p>For example, if the minimum weight to maximum weight reads as 0 and 5 for FedEx Australia, I need 5 rows from 1 to 5.</p>
  <p>I need these <strong>4 columns</strong> in the new Couriers_FlattenedData table - Courier, Country, Weight, Freight. The Weight column is converted to rows based on the range in the source table.</p>
  <p>I am trying to derive the new table, in both <strong>DAX</strong> as well as using the <strong>backend Power Query Editor</strong> (using M language). I would like to get both ways to develop this new table.</p>
  <p>I tried something like this in DAX, but not able to get a solution.</p>
  <pre><code>Couriers_FlattenedData = SELECTCOLUMNS (
      
                                           GENERATE (
  
                                                      'Couriers',  GENERATESERIES (
  
                                                                                  CALCULATE(DISTINCT(Couriers[MinWeight])+1),
  
                                                                                  CALCULATE(DISTINCT(Couriers[MaxWeight]))
  
                                                                                )
  
                                                    ),
  
                                           &quot;Courier&quot;, Couriers[Courier],
  
                                           &quot;Country&quot;, Couriers[Country],
  
                                           &quot;Freight&quot;, Couriers[Freight]
  
                                          )
  </code></pre>
  <p>Can someone correct the above DAX expression, which misses the Weight column ? Or even provide a solution using variables?</p>
  <p>And also a step by step solution using the Power Query Editor of Power BI ?</p>