Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
hackfifi
Helper V
Helper V

Create Duplicate Entries based on Column Value

Good Day - I have a table in PowerBI Query as DATA [shown below]

I am trying to convert that DATA to OUTPUT [shown below]

In summary, Each ROW needs to be duplicated based on COUNT value, and ID Column needs to be added for that set of duplicate data.

 

Appreciate any help to make this possible!

 

Duplicate Query.PNG

1 ACCEPTED SOLUTION
Phil_Seamark
Employee
Employee

Hi @hackfifi

 

You could try this calculated table in DAX

 

Table 2 = 
    GENERATE(
        'Table',
         FILTER(
             SELECTCOLUMNS(
                 GENERATESERIES(1,100),
                 "ID",[Value]
                 ),
                 [ID]<=[Count])
                 )

This gave me this result

 

 

image.png


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

7 REPLIES 7
Phil_Seamark
Employee
Employee

Hi @hackfifi

 

You could try this calculated table in DAX

 

Table 2 = 
    GENERATE(
        'Table',
         FILTER(
             SELECTCOLUMNS(
                 GENERATESERIES(1,100),
                 "ID",[Value]
                 ),
                 [ID]<=[Count])
                 )

This gave me this result

 

 

image.png


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

I need to do the same thing but in Power Query. Any idea how?

@Phil_Seamark - Mate you never fail to disappoint!

Couple of Queries:

1. Using the Generate Table function, i assume now i cannot accesss the new generated table via Query Editor to make some changes?

2. I am trying to understand your formular - what does "GenerateSeries(1,100) do?

Thanks again!

Hi @hackfifi

 

The GenerateSeries function just creates a single column table with values between 1 and 100

 

if you create a new calculated table and use just that function you will see what it looks like.

 

I wrapped it with the SELECTCOLUMNS function, simply to rename the column as you already had a column called [Value] in your first column.


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Ok @Phil_Seamark - So i am doing SOMETHING wrong. Obviously the below the "REAL" data, not the SAMPLE table i provided earlier. As you can see each row has count value of "19" in this case. Hence  the generated table should show each row 19 times i.e. it should have 57 rows of data

 

Duplicate Query2.PNG

 

 

Hi @hackfifi

 

Make sure the data type of your [Count] column is set to int.  Try that...


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Yes the "Count" column on Main Table is of Type "Whole Number"....
Maybe i will import the data and start again

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors