Forum Discussion
rezaaditia
7 years agoHelper III
create weekly date
Hi - please help with the dax formula to create combination of week and date of every monday. basically we want to create weekly report and if we use week numbers, it will be difficult to unders...
- Anonymous7 years ago
Hi rezaaditia ,
I hope you have a calendar ( date ) table in your model.
Do the following
1. Create a calculated column called Week
Week = WEEKNUM([Date],2)2. Create another calculated column WeekNameWeekName = "W-" &FORMAT(CALCULATE( MIN('Calendar'[Date]),This will give the output as desired.Filter('Calendar','Calendar'[Week] = EARLIER('Calendar'[Week]) )),"MM/DD")CheersCheenuSing - Anonymous7 years ago
Hi rezaaditia ,
Try the following
1. Add another column
YearWeek = Year(Table[Date]) * 100 + Table[WeekNum]
( Replace Table by your tablename)
2. Using the modelling tab set the Sort order for WeekName to YearWeek.
Cheers
CheenuSing
- Anonymous7 years ago
Hi rezaaditia ,
You should not add the YearWeek in the axis name.
what you should do is select the Calculated column WeekName in the Fields pane.
Go to the modelling pane
From the sort by column set it to YearWeek.
Cheers
CheenuSing
Mariusz
7 years agoCommunity Champion
Hi rezaaditia
Please see the below Query Editor solution.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XdGxDYNAEEXBXogtcbtnzKcWRP9tQOJgCF820jvPZdQ69rVHHcv1ebLNaX7NzfyZuxnzIGuYqkpVqSpVpapUlapSVapaVatqVa2qVbWqVtWqWlWrmqrm6+CTcWgcGofGoXFoHBqHxqFxaBwah8ahceg/rxs=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Date = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "week", each Date.WeekOfYear([Date]), Int64.Type),
#"Grouped Rows" = Table.Group(#"Added Custom", {"week"}, {{"weekStart", each List.Min([Date]), type date}}),
#"Added Custom1" = Table.AddColumn(#"Grouped Rows", "Week Day", each "W-" & Text.PadStart( Number.ToText( Date.Month( [weekStart] ) ), 2, "0" ) & "/" & Text.PadStart( Number.ToText( Date.Day( [weekStart] ) ), 2, "0" ), type text),
#"Merged Queries" = Table.NestedJoin(#"Added Custom", {"week"}, #"Added Custom1", {"week"}, "Added Custom1", JoinKind.LeftOuter),
#"Expanded Added Custom1" = Table.ExpandTableColumn(#"Merged Queries", "Added Custom1", {"Week Day"}, {"Week Day"}),
#"Removed Other Columns" = Table.SelectColumns(#"Expanded Added Custom1",{"Date", "Week Day"})
in
#"Removed Other Columns"
Best Regards,
Mariusz
If this post helps, then please consider Accepting it as the solution.
Please feel free to connect with me.

Mariusz
If this post helps, then please consider Accepting it as the solution.
Please feel free to connect with me.
