Forum Discussion
Rolling 3 months not working properly
- 1 year ago
You would need separate date tables for the visual and for the slicer. You can use the method described in the article I posted, or you could just have a disconnected copy of your date table which you use on the slicer, using the current date table in the visuals, and change the code to
Last 3 months = VAR HasMonthSelected = ISFILTERED ( 'CustomCalendar for slicer'[MonthName] ) VAR EndDate = MAX ( 'CustomCalendar for slicer'[Date] ) VAR SelectedDate = MAX ( 'CustomCalendar'[Date] ) VAR Result = SWITCH ( TRUE (), HasMonthSelected && SelectedDate IN DATESINPERIOD ( 'CustomCalendar'[Date], EndDate, -3, MONTH ), 1, HasMonthSelected, 0, 1 ) RETURN Result
You could use the technique described in https://www.sqlbi.com/articles/show-previous-6-months-of-data-from-single-slicer-selection/
- DineshArivu1 year ago
Helper I
johnt75 hey john,
we are using data everything from a measure (Y axis), not from fact table.
Calendar table (Date table) is not visible when trying to apply IF condition in the dax.
FarhanJeelani
Selva-SalimiLast3Months =VAR HasMonthSelected = ISFILTERED('CustomCalendar'[MonthName])VAR EndDate = MAX('CustomCalendar'[MonthName])VAR StartDate = EOMONTH(EndDate, -2) + 1RETURNIF(HasMonthSelected, IF( ..- johnt751 year ago
Super User
You can't work with the MAX of a month name, you could try
Last 3 months = VAR HasMonthSelected = ISFILTERED ( 'CustomCalendar'[MonthName] ) VAR EndDate = CALCULATE ( MAX ( 'CustomCalendar'[Date] ), ALLSELECTED ( 'CustomCalendar' ) ) VAR SelectedDate = MAX ( 'CustomCalendar'[Date] ) VAR Result = SWITCH ( TRUE (), HasMonthSelected && SelectedDate IN DATESINPERIOD ( 'CustomCalendar'[Date], EndDate, -3, MONTH ), 1, HasMonthSelected, 0, 1 ) RETURN Result- DineshArivu1 year ago
Helper I
johnt75 thanks john, i have applied this dax measure in visual filter and set 1 ,
but nothing reflects when select any month from the slicer.
still it is displaying as it is normally - selected month data only , not last 3 months.