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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Merge alternative columns dynamically used in a function

Hi,

 

So I have this data in multiple files in a folder. The data is formated in the following way:

First column: Date and time

Second column: Measured value of series 1

Third column: Status of measured value  series 1

Forth column: Measure value of series 2

Fifth column: Status value of series 2

 

Sample:

TimestampValue 1Status 1Value 2Status 2   ...Value NStatus N
2017-12-01 00:004Calculated3  1 
2017-12-01 01:003Calculated2Estimated 6 
2017-12-01 02:002Calculated6  8Calculated
2017-12-01 03:000Calculated8  5Calculated

 

 

The amount of columns is dependent on how many series is in that file. I would like to make a function to clean and make the data neat for all the files in the folder. I do this by merging the column Measured value and Status and then splitting it and normalizing it. But since the data has different amount of columns cross the files I'm having a hard time creating a function for this. Anybody have any good suggestions to create a function to merge every other column except the first one, independent on number of columns? 

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

If all files in a folder have the same format, you could Get Data from Folder with Power BI,

Then Click Edit, expand the "Content"

7.png

 

Select "Source.Name" and "Timestamp" columns and unpivot other columns

8.png

Rename the "Value" column to "combine Status"

9.png

Spilt the "Attribute" column 

10.png

rename "Attribute.2" to "Series"

Select ""Attribute.2" and pivot columns

11.png

 

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

If all files in a folder have the same format, you could Get Data from Folder with Power BI,

Then Click Edit, expand the "Content"

7.png

 

Select "Source.Name" and "Timestamp" columns and unpivot other columns

8.png

Rename the "Value" column to "combine Status"

9.png

Spilt the "Attribute" column 

10.png

rename "Attribute.2" to "Series"

Select ""Attribute.2" and pivot columns

11.png

 

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @Anonymous,

you've already get a solution from @v-juanli-msft.

But an alternative could be using functions like Table.ColumnNames or Record.FieldNames. You get a list of all columns of a table or a record which you can filter with List.Select. And then you can do your magic. It expects more programming skills in M.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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