Forum Discussion
Oomsen
Helper III
7 years agoMonthly value by week
I would like to show a monthly value by week.
Month Week Value
January 1 337.500
2
3
4
5
February 6 335.000
7
Currently the value is only shown by month. I would like to see 337.500 in week 2, 3, 4 and 5.
The data is add from a custom excelsheet.
Hi Oomsen
Please see the below M code, this will expand your months to weeks.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUByIjA0MLJR2lQwsUYMjYzNzUwODQAqCoMUJJrA5EhxFWHUANEB1GFnAlMB3GWHUYIdsBVRIbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Date = _t, Value = _t, #"End date" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Value", Int64.Type}, {"End date", type date}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.Distinct( List.Transform( List.Dates( [Date], Duration.Days( [End date] - [Date] ), #duration( 1, 0, 0, 0 ) ), each Date.WeekOfYear(_) ) )), #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"), #"Changed Type1" = Table.TransformColumnTypes(#"Expanded Custom",{{"Custom", type number}}) in #"Changed Type1"Best Regards,
Mariusz
If this post helps, then please consider Accepting it as the solution.
Please feel free to connect with me.
9 Replies
- v-chuncz-msft
Community Support
- Oomsen
Helper III
Thanks for your reaction.
Can you be a little more specific where i need to add this in the query editor.