Forum Discussion
Based on current week selection in Slicer Previous 6 weeks data display under line/bar chart
- Anonymous9 years ago
Anonymous
For this case, I think you need a calendar table as below. And then create a one to many relationship between your table and dim_date.
dim_date =
VAR TBL =
FILTER (
ADDCOLUMNS (
CALENDAR ( "2016-01-01", "2017-12-31" ),
"WEEKDAY", WEEKDAY ( [Date] )
),
[WEEKDAY] = 7
)
RETURN
ADDCOLUMNS ( TBL, "RANK", RANKX ( TBL, [Date],, ASC ) )
To get the data for last 6 weeks, create a measure like
measure =
SUMX (
FILTER (
ALL ( yourTable ),
dim_date[RANK] <= MAX ( dim_date[RANK] )
&& dim_date[RANK]
>= MAX ( dim_date[RANK] ) - 6
),
[somecolumn]
)
Eric_Zhang Thanks to reply on my Post, I'm new in Power BI and DAX coluld you please explain more brifly how its work's when i selectd current year in slicer it returns 6 weeks data under Line chart including current week. Please explain More its helps me.
- Eric_Zhang9 years ago
Microsoft Employee
Anonymous
I think the solution shall work. Have you tried in your case? If you can post the sample in your case, I can explain the DAX accordingly.
- Anonymous9 years agoNot applicable
Thanks Eric_Zhang i tried another Solution and that's works for me . Thanks for your reply and help.
- Eric_Zhang9 years ago
Microsoft Employee
Anonymous
Could you share your approach and accept it as solution to close this thread? People who have the similar question can benenif from the solution. :)