Forum Discussion
Sorting X- axis based on Month-Year slicer selection
- 6 months ago
You can use
PL12M Amount = VAR MaxDate = MAX ( 'Date'[Date] ) VAR StartDate = EOMONTH ( MaxDate, -12 ) + 1 VAR MaxDupeDate = MAX ( 'Dupe Date'[Date] ) VAR Result = IF ( MaxDupeDate >= StartDate && MaxDupeDate <= MaxDate, VAR Result = CALCULATE ( SUM ( Sheet1[consum] ), SAMEPERIODLASTYEAR ( 'Dupe Date'[Date] ), REMOVEFILTERS ( 'Date' ), USERELATIONSHIP ( 'Date'[Date], 'Dupe Date'[Date] ) ) RETURN Result ) RETURN ResultI tried this in a dummy model and it worked.
You need the year for context, but what you could maybe do is create a new date type column, set to the start of the month, but set the format string to be "mmm" so it only shows the month.
Do you mean that Year needs to be included on the X-axis for the measure to return values? Is that correct?
- Anonymous6 months agoNot applicable
Hi SSRk,
The measure needs the year information to calculate the correct values. If you use only the month name (Jan to Dec) on the X axis and remove the year, Power BI cannot tell which year the month belongs to. Because of this missing context, time intelligence functions may return blank values. A good solution is to use a date column that includes both year and month, but format it to display only the month name. This way Power BI still has the correct date context for calculations, while the visual shows only the month names.
Thanks & Regards,
Prasanna Kumar