Forum Discussion
Dynamic chart X axis - dates
- 5 years ago
Hi Metricbits !
You can create a new measure using following DAX;Assets Last (N) Month = VAR _CurrentMonth = MAX('Calendar'[Date]) VAR _LastNMonths = -12 VAR _DatesPeriod = DATESINPERIOD('Calendar'[Date], _CurrentMonth, _LastNMonths, MONTH) RETURN CALCULATE([Assets], _DatesPeriod)This measure will return the Last (N) months (in this case Last 12 months) [Assets] value. Assuming you have Assets measure.
You can replace the [Assets] wiht your actual measure, it will bring Last 12 months value for that mesure.
You can have still have your Calendar / Date dimension table connected to your Fact table. From Date slicer it will pick up the selected date value & then go back 12 months.
To plot this on chart, you need to create a Dummy date column in your Fact table using below DAX;
Calendar = EOMONTH(FactTable[Date], 0)[FactTable] will be the name of your Fact tabl & Date will be its date column. Now you use this field in your chart axis & place [Assets Last (N) Months] measure into values.
Regards,
Hasham
Hi Metricbits !
You can create a new measure using following DAX;
Assets Last (N) Month =
VAR _CurrentMonth = MAX('Calendar'[Date])
VAR _LastNMonths = -12
VAR _DatesPeriod = DATESINPERIOD('Calendar'[Date], _CurrentMonth, _LastNMonths, MONTH)
RETURN
CALCULATE([Assets], _DatesPeriod)
This measure will return the Last (N) months (in this case Last 12 months) [Assets] value. Assuming you have Assets measure.
You can replace the [Assets] wiht your actual measure, it will bring Last 12 months value for that mesure.
You can have still have your Calendar / Date dimension table connected to your Fact table. From Date slicer it will pick up the selected date value & then go back 12 months.
To plot this on chart, you need to create a Dummy date column in your Fact table using below DAX;
Calendar = EOMONTH(FactTable[Date], 0)
[FactTable] will be the name of your Fact tabl & Date will be its date column. Now you use this field in your chart axis & place [Assets Last (N) Months] measure into values.
Regards,
Hasham
Worked like magic. Thank you so much!