powerbidaxpowerbi-datasource

For loop from column to table


How do you loop through a column of data to create a table with. The number of columns will be constant based on the first x number of rows but the number number of entries will vary based on the number of personnel records. The database pull gives all the data in a single column, but it needs to be formatted to a table.

Default format

General Data
Name
Age
City
Bob
31
Paris
John
24
Washington
Jill
45
Vancouver

The first X number of rows would be the table headers, and the following series of rows would be the data in each column.

Desired Format

Name Age City
Bob 31 Paris
John 24 Washington
Jill 45 Vancouver

Solution

  • you can try this in PQ

    create two index columns and modulo one column

    enter image description here

    select index column and pivot columns

    enter image description here

    modulo index 1column

    enter image description here

    select three columns and fill down

    enter image description here

    at last filter index 1 = 2

    enter image description here