Forum Discussion
Dax formula to get week data
- 2 years ago
You can create a 'WeekOfMonth' column on your Date Dimension that assigns the WeekOfMonth number by the Week Ending date. Then you can write DAX variables to leverage the WeekOfMonth Number to get your comps in your DAX measure(s)
- Anonymous2 years ago
Hi Chandu_sandy ,
I created some simple data to help you solve the problem, you can follow these steps below:
1.Create a new table.
Table = VAR _table = ADDCOLUMNS ( CALENDAR ( DATE ( 2023, 12, 1 ), TODAY () ), "Week", WEEKNUM ( [Date] ), "Month", MONTH ( [Date] ) ) RETURN _table2.Create a new column.
MonthWeek = VAR _1 = WEEKNUM ( [Date] ) - WEEKNUM ( DATE ( 2023, 12, 1 ) ) + 1 RETURN IF ( 'Table'[Week] > 6, _1, 'Table'[Week] )total = CALCULATE ( SUM ( 'Table'[SalesAmount] ), FILTER ( ALL ( 'Table' ), 'Table'[Month] = EARLIER ( 'Table'[Month] ) && 'Table'[MonthWeek] = EARLIER ( 'Table'[MonthWeek] ) ) )Final output:
How to Get Your Question Answered Quickly - Microsoft Fabric Community
If it does not help, please provide more details with your desired out put and pbix file without privacy information.
Best Regards,
Yifan Wang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
You can create a 'WeekOfMonth' column on your Date Dimension that assigns the WeekOfMonth number by the Week Ending date. Then you can write DAX variables to leverage the WeekOfMonth Number to get your comps in your DAX measure(s)