Forum Discussion
Anonymous
1 year agoNot applicable
Last 6 Weeks
Hello, Could you help with me with a dax measure to calculate and display dynmically only last 6 weeks from the time period year-week selected in the slicer? Values should correspond with a singl...
- Anonymous1 year ago
Hi Anonymous ,
I create two tables as you mentioned.
Caleadar = VAR StartYear = YEAR ( NOW () ) - 5 VAR EndYear = YEAR ( NOW () ) + 5 RETURN ADDCOLUMNS ( CALENDAR ( DATE ( StartYear, 1, 1 ), DATE ( EndYear, 12, 31 ) ), "Year", YEAR ( [Date] ), "Date_Key", VALUE ( FORMAT ( [Date], "YYYYMMDD" ) ), "Month", MONTH ( [Date] ), "Month Name", FORMAT ( [Date], "MMMM" ), "Day", DAY ( [Date] ), "Year Month", VALUE ( FORMAT ( [Date], "YYYYMM" ) ), "Week", WEEKDAY ( [Date], 2 ), "Month Abbr", FORMAT ( [Date], "MMM" ), "Weekday Abbr", FORMAT ( [Date], "DDD" ), "Quarter", QUARTER ( [Date] ), "Quarter Name", "Q" & CONVERT ( QUARTER ( [Date] ), STRING ) )Year List = SELECTCOLUMNS ( GENERATESERIES ( 2018, 2028, 1 ), "Year", [Value] )Next I think you can create a measure and add it to Filter.
Is Show = VAR SelectedYear = SELECTEDVALUE ( 'Year List'[Year] ) VAR CurrentYear = SELECTEDVALUE ( 'Caleadar'[Year] ) RETURN IF ( CurrentYear <= SelectedYear, "Y", "N" )Finally you will get what you want.
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
1 year agoNot applicable
Hi Anonymous ,
I create two tables as you mentioned.
Caleadar =
VAR StartYear =
YEAR ( NOW () ) - 5
VAR EndYear =
YEAR ( NOW () ) + 5
RETURN
ADDCOLUMNS (
CALENDAR ( DATE ( StartYear, 1, 1 ), DATE ( EndYear, 12, 31 ) ),
"Year", YEAR ( [Date] ),
"Date_Key", VALUE ( FORMAT ( [Date], "YYYYMMDD" ) ),
"Month", MONTH ( [Date] ),
"Month Name", FORMAT ( [Date], "MMMM" ),
"Day", DAY ( [Date] ),
"Year Month", VALUE ( FORMAT ( [Date], "YYYYMM" ) ),
"Week", WEEKDAY ( [Date], 2 ),
"Month Abbr", FORMAT ( [Date], "MMM" ),
"Weekday Abbr", FORMAT ( [Date], "DDD" ),
"Quarter", QUARTER ( [Date] ),
"Quarter Name", "Q" & CONVERT ( QUARTER ( [Date] ), STRING )
)Year List =
SELECTCOLUMNS ( GENERATESERIES ( 2018, 2028, 1 ), "Year", [Value] )
Next I think you can create a measure and add it to Filter.
Is Show =
VAR SelectedYear =
SELECTEDVALUE ( 'Year List'[Year] )
VAR CurrentYear =
SELECTEDVALUE ( 'Caleadar'[Year] )
RETURN
IF ( CurrentYear <= SelectedYear, "Y", "N" )
Finally you will get what you want.
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.