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
jhaast
Helper II
Helper II

Create a table with repeated labels

Hi everybody,

 

I'm trying to create a new table with repeated labels.

Table A is a table with dates, Table B is a table with the business units.

I want to create a table which repeats the date values for n number of business units as shown in table C.

Table A:

Date
2020-1-1
2020-1-2
2020-1-3

2020-1-4

2020-1-5

 

Table B:

BusinessUnit
BusinessUnitA
BusinessUnitB
BusinessUnitC
BusinessUnitD
BusinessUnitE

 

Table C:

DateBusinessUnit
2020-1-1BusinessUnitA
2020-1-1BusinessUnitB
2020-1-1BusinessUnitC
2020-1-1BusinessUnitD
2020-1-1BusinessUnitE
2020-1-2BusinessUnitA
2020-1-2BusinessUnitB
2020-1-2BusinessUnitC
2020-1-2BusinessUnitD
2020-1-2BusinessUnitE
2020-1-3BusinessUnitA
2020-1-3BusinessUnitB
2020-1-3BusinessUnitC
2020-1-3BusinessUnitD
2020-1-3BusinessUnitE

 

Does somebody know which formula I could use to create this table? Or is this actually possible?

1 ACCEPTED SOLUTION

OK, you have two choices:

1. Create the date table in Power Query and Add the column as in the first post.

 

Or

2. Create the new table in DAX which would be CROSSJOIN (Table A, Table B)

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

You can simply add a column with this formula:

=Text.Repeat("a",[Column5])

In column 5 should be the count you want for rows to be duplicated.

Then, from transform tab, split the new column by number of characters, use 1 char split, but from advanced settings, make sure you split into rows, not into columns, this will duplicate all other columns.

Now you can remove the additional column, to diplay only the results.

I can be done with custom M code, with List.Accumulate, but it's easier via interface, see the attached file.

HotChilli
Super User
Super User

In Power Query, Add a custom column to the date table(Table A).

The custom column should be the name of the other table (Table B - the intellisense will complete it once you start typing)

The date table A is created after the Power Query menu, with the new table function and the following formula:

 
Dates = CALENDAR (DATE(2003;01;1); DATE(YEAR(TODAY())+1;12;31))
 
The Business Unit table B is imported from a SQL database with Power Query.

OK, you have two choices:

1. Create the date table in Power Query and Add the column as in the first post.

 

Or

2. Create the new table in DAX which would be CROSSJOIN (Table A, Table B)

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.