DAX Help - Displaying Selected Months

Hi ALL,

Basically i want to implement “Display selected Months” Dax code.

The approach is and logic is exactly same as this link -
https://www.sqlbi.com/blog/alberto/2018/12/20/displaying-a-list-of-selected-months/.

The pbix is also available in the link above. And the code used is the new code mentioned in the link itself.

Sel ( much better version ) =

VAR SelectedMonthNumbers =

VALUES ( 'Date'[Month Number] )

VAR MonthsAndNames =

SUMMARIZE ( 'Date' , 'Date'[Month Number] , 'Date'[Month] )

VAR Result =

CONCATENATEX (

MonthsAndNames ,

VAR CurrentMonthNumber = 'Date'[Month Number]

VAR CurrentMonthName = 'Date'[Month]

VAR IsNextSelected = CurrentMonthNumber + 1 IN SelectedMonthNumbers

VAR IsPrevSelected = CurrentMonthNumber - 1 IN SelectedMonthNumbers

RETURN

IF (

NOT ( IsPrevSelected && IsNextSelected ) ,

CurrentMonthName & IF ( IsNextSelected , "-" , ", " )

) ,

"" ,

'Date'[Month Number]

)

RETURN

LEFT ( Result , LEN ( Result ) - 2 )

but the issue i am facing is if i dont select any months it is currently displaying January-December whereas i want to see blank.

This is resolved now.

Just wondering if you can put your solution within the message, so everyone can learn too. :slight_smile: thank you…make mark solution done

1 Like

To the contributor of this post. Thank you for sharing your experiences around Power BI, please don’t hesitate to add more discussion or add value to wherever you think you possess the experience or knowledge that can help others in our Ecosystem Group. You can also help us in improving the Support forum further by answering the Enterprise DNA Forum User Experience Survey. We appreciate the initiative and your help in this group!