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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Amardeep100115
Post Prodigy
Post Prodigy

How to Create data table from row data in power query

Hello Sir,

 

I wish to create table like below table in power query with same below results. Also please note i have not added week of the month in smaple data sheet b'coz i want to learn to create it in power query and in table.

 

once the result table get created, want to filter table with max granc total of the month. 

 

 

https://1drv.ms/x/s!Ai3rGPgy20kLwXL2cj0-2zXoR1b8?e=vb8D3A

 

Result Table.JPG

Amardeep Bhingardeve
1 ACCEPTED SOLUTION

Hi @Amardeep100115 ,

You could use the function of  List.Max  and List.Min. Try the code below. 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VZDBDcMwDAN3ybtAZUmW3VmK7r9GQ7ZhoA8N+GJRuff78Od4uo19PI5hdqbbeXweIH4R/xEXCb2ZJPkneU87v0aWyD0tJ3KLaJqvOjNMJC8StpDXBvvuiWCmiHqiXkwR9ST/J7aIejLGj19kipQjbwfcAA35CmR2byDTky+7N5IJB7lFUmTDwbRuFKTG4sxulCSx4cxulGRxZnWjuFvD2CYyRRIOyrprkgUH5d01yLbgHt01ScBBVXdNUnBQ3ODzBQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Date = _t, Office = _t, Workstatics = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Office", Int64.Type}, {"Workstatics", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Grand Total", each [Office] +[Workstatics]),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Week of Month", each Date.WeekOfMonth([Date])),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom1", each true),
    #"Added Custom2" = Table.AddColumn(#"Filtered Rows", "Custom", each List.Max(#"Changed Type"[Date]))
in
    #"Added Custom2"

Best Regards,

Xue Ding

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

Best Regards,
Xue Ding
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

7 REPLIES 7
v-xuding-msft
Community Support
Community Support

Hi @Amardeep100115 ,

The file hits the limitation of 5M for Excel online so that I can't view it. I created a sample based on your screenshot to create two new columns of Week of Month and Grand Total.

Query Editor (M Language):

 

6.PNG9.PNG

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VZDBDcMwDAN3ybtAZUmW3VmK7r9GQ7ZhoA8N+GJRuff78Od4uo19PI5hdqbbeXweIH4R/xEXCb2ZJPkneU87v0aWyD0tJ3KLaJqvOjNMJC8StpDXBvvuiWCmiHqiXkwR9ST/J7aIejLGj19kipQjbwfcAA35CmR2byDTky+7N5IJB7lFUmTDwbRuFKTG4sxulCSx4cxulGRxZnWjuFvD2CYyRRIOyrprkgUH5d01yLbgHt01ScBBVXdNUnBQ3ODzBQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Date = _t, Office = _t, Workstatics = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Office", Int64.Type}, {"Workstatics", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Grand Total", each [Office] +[Workstatics]),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Week of Month", each Date.WeekOfMonth([Date])),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom1", each true)
in
    #"Filtered Rows"

7.PNG

Report View (DAX):

Week of Month (DAX) = 1 + WEEKNUM ( 'Table'[Date] ) - WEEKNUM ( STARTOFMONTH ( 'Table'[Date] ) )

I attached my sample that you can download.

 

Best Regards,

Xue Ding

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

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Great Help,

 

Just need add one more step after creating table i wish to filter either First file/Date of the month or last file/Date of the month.

 

Is it posible? it will be greate help as like above. 

Thank you !!

 

so i can have updated details 

 

filter.JPG

Amardeep Bhingardeve

Hi @Amardeep100115 ,

How do you want to filter? Just show the earliest date?

  • You could put date to a card visual and shown as earliest or latest date.

2.PNG

  • Or you could create formulas.
Earliest date = MIN( 'Table'[Date])
Latest date = MAX('Table'[Date])

3.PNG

Best Regards,

Xue Ding

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

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

looking for filter in power query,  don't want to create visual. 

Amardeep Bhingardeve

Hi @Amardeep100115 ,

You could use the function of  List.Max  and List.Min. Try the code below. 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VZDBDcMwDAN3ybtAZUmW3VmK7r9GQ7ZhoA8N+GJRuff78Od4uo19PI5hdqbbeXweIH4R/xEXCb2ZJPkneU87v0aWyD0tJ3KLaJqvOjNMJC8StpDXBvvuiWCmiHqiXkwR9ST/J7aIejLGj19kipQjbwfcAA35CmR2byDTky+7N5IJB7lFUmTDwbRuFKTG4sxulCSx4cxulGRxZnWjuFvD2CYyRRIOyrprkgUH5d01yLbgHt01ScBBVXdNUnBQ3ODzBQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Date = _t, Office = _t, Workstatics = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Office", Int64.Type}, {"Workstatics", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Grand Total", each [Office] +[Workstatics]),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Week of Month", each Date.WeekOfMonth([Date])),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom1", each true),
    #"Added Custom2" = Table.AddColumn(#"Filtered Rows", "Custom", each List.Max(#"Changed Type"[Date]))
in
    #"Added Custom2"

Best Regards,

Xue Ding

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

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you So much for your Super guidance
Amardeep Bhingardeve

Hi @Amardeep100115 ,

I‘m glad to cooperate you to deal with it. Smiley Wink

 

Best Regards,

Xue Ding

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

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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.

Top Kudoed Authors