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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
NZCraig
Helper I
Helper I

Making a single row with multiple new columns

Hi, I have an SQL extract that produces a table forecasting the dates for mainteance events but it produces a row for each event, with a single week-year that the activity would take place. I would like to group all the other data and and add extra columns for the recuring events. Is this possible ( I have approximately 7000 rows, and dates going all the way out to the year 2044) ? Thanks in advance.
A sample table and desired results look like:
Sample

SiteIDLocFreqPM NumJP NumTypeWeek
TPOTPO14 WT1436JP4739PM2024-01
HAMHAM13 MZ1049JP8508PM2024-01
WLGWLG/0212 MG1190JP2353CM2024-01
TPOTPO14 WT1436JP4739PM2024-05
TPOTPO14 WT1436JP4739PM2024-09
HAMHAM13 MZ1049JP8508PM2024-13
TPOTPO14 WT1436JP4739PM2024-13
TPOTPO14 WT1436JP4739PM2024-17
TPOTPO14 WT1436JP4739PM2024-21
HAMHAM13 MZ1049JP8508PM2024-25
TPOTPO14 WT1436JP4739PM2024-25

 

Desired result

 

SiteIDLocFreqPM NumJP NumTypeWeekWeek (1)Week (2)Week (3)Week (4)Week (5)Week (6)
TPOTPO14 WT1436JP4739PM2024-012024-052024-092024-132024-172024-212024-25
HAMHAM13 MZ1049JP8508PM2024-012024-13nullnullnullnullnull
WLGWLG/0212 MG1190JP2353CM2024-01nullnullnullnullnullnull


Or the result could be as follows, I don't mind 🙂

SiteIDLocFreqPM NumJP NumWorktype2024-012024-022024-032024-042024-052024-062024-072024-082024-092024-102024-112024-122024-132024-142024-152024-162024-172024-182024-192024-202024-212024-222024-232024-242024-25
TPOTPO14 WT1436JP4739PM1111111111111111111111111
HAMHAM13 MZ1049JP8508PM1000000000001000000000001
WLGWLG/0212 MG1190JP2353CM1000000000000000000000000
1 ACCEPTED SOLUTION
mussaenda
Super User
Super User

Hi @NZCraig ,

 

Yo can Pivot the Week by Type.

Buuuuut. It is advisable to have more columns than to have more columns

 

Why do you need to do this kind of step in M query?

If you just want to show the data by week, you can use the matrix visual instead of doing it here

View solution in original post

1 REPLY 1
mussaenda
Super User
Super User

Hi @NZCraig ,

 

Yo can Pivot the Week by Type.

Buuuuut. It is advisable to have more columns than to have more columns

 

Why do you need to do this kind of step in M query?

If you just want to show the data by week, you can use the matrix visual instead of doing it here

Helpful resources

Announcements
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.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.