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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
kvbe
Frequent Visitor

Power Query conversion from single columns to multiple columns based on rowname index

For my datamodel I need to convert a table I fetch from a database into a more easy format to work with in Power BI.

The table I receive from the database is this one. (after some cleanup and transposing it)

 

CurYrPrdStat1C
CurYrPrdStat2C
CurYrPrdStat3O
CurYrPrdStat4C
CurYrPrdStat5C
CurYrPrdStat6C
CurYrPrdStat7C
CurYrPrdStat8C
CurYrPrdStat9C
CurYrPrdStat10C
CurYrPrdStat11C
CurYrPrdStat12C
CurYrPrdStat13C
CurYrPrdStat14 
CurYrPrdStat15C
CurYrPrdEnd131/07/2018 00:00
CurYrPrdEnd231/08/2018 00:00
CurYrPrdEnd330/09/2018 00:00
CurYrPrdEnd431/10/2018 00:00
CurYrPrdEnd530/11/2018 00:00
CurYrPrdEnd631/12/2018 00:00
CurYrPrdEnd731/01/2019 00:00
CurYrPrdEnd828/02/2019 00:00
CurYrPrdEnd931/03/2019 00:00
CurYrPrdEnd1030/04/2019 00:00
CurYrPrdEnd1131/05/2019 00:00
CurYrPrdEnd1230/06/2019 00:00
CurYrPrdEnd1330/06/2019 00:00
CurYrPrdEnd14null
CurYrPrdEnd15null

 

Using power Query, I would like to achieve following format:

 

PeriodCurrentPeriodEndDateCurrentStatus
Period 131/07/2018 00:00C
Period 231/08/2018 00:00C
Period 330/09/2018 00:00O
Period 431/10/2018 00:00C
Period 530/11/2018 00:00C
Period 631/12/2018 00:00C
Period 731/01/2019 00:00C
Period 828/02/2019 00:00C
Period 931/03/2019 00:00C
Period 1030/04/2019 00:00C
Period 1131/05/2019 00:00C
Period 1230/06/2019 00:00C
Period 1330/06/2019 00:00C
Period 14null 
Period 15nullC

 

So basically what I would like to achieve is using the index number (eg. CurYrPrdEnd1) and use that one as a value. 

I tried but do not really see how I could convert this using the power query editor. 

 

After that I would like to use this table to augment my datetable I generated with the

period number added to the datetable. 

 

Something like:

 

01/07/2018 Period 1 

...

31/07/2018 Period 1

01/08/2018 Period 2 

 

etc. 

 

This using the period end date specified.

I have the date table etc and merging it with this new table I should be able to manage, just sure about the two questions regarding getting it in the right format.

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

hi,@kvbe

    After my research, you can do these follow my steps as below:

Basic data

17.PNG

Step1:

Select column A and duplicate this column

and then select the duplicate column replace value

18.PNG

Step2:

duplicate the table

Step3:

Merge basic table with duplicate table

19.PNG

And then expand the table

20.PNG

Step4:

Add a conditional column

21.PNG

Step5:

filter custom column is 2

22.PNG

Step6:

Add the index column

23.PNG

Step7:

select Index column ,click Add Column->Standard->Modulo

24.PNG

25.PNG

Step8

filter column Modulo is 0

Step9:

select Column A and replace the value

26.PNG

Step10:

Remove unnecessary column and rename the column

 

Result:

27.PNG

 

here is demo, please try it.

https://www.dropbox.com/s/ablf38rvrhravgf/Power%20Query%20conversion%20from%20single%20columns%20to%...

 

Best Regards,

Lin

 

 

 

 

Community Support Team _ Lin
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-lili6-msft
Community Support
Community Support

hi,@kvbe

    After my research, you can do these follow my steps as below:

Basic data

17.PNG

Step1:

Select column A and duplicate this column

and then select the duplicate column replace value

18.PNG

Step2:

duplicate the table

Step3:

Merge basic table with duplicate table

19.PNG

And then expand the table

20.PNG

Step4:

Add a conditional column

21.PNG

Step5:

filter custom column is 2

22.PNG

Step6:

Add the index column

23.PNG

Step7:

select Index column ,click Add Column->Standard->Modulo

24.PNG

25.PNG

Step8

filter column Modulo is 0

Step9:

select Column A and replace the value

26.PNG

Step10:

Remove unnecessary column and rename the column

 

Result:

27.PNG

 

here is demo, please try it.

https://www.dropbox.com/s/ablf38rvrhravgf/Power%20Query%20conversion%20from%20single%20columns%20to%...

 

Best Regards,

Lin

 

 

 

 

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

Hi Lin,

 

Thank you very much thats a neat way of approaching this! 

Never thought about the merging + index + modulo approach. 

 

Another type of technique I can add to my power query toolbox.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.