Selected Value as a dynamic header

Frequent Visitor
1769 Views
Highlighted
Frequent Visitor
Posts: 4
Registered: ‎07-23-2017

Selected Value as a dynamic header

Most reports I make have a dynamic header using the Enlighten Data Story where I show which filter values the user has currently selected as they interact with the report.

 

Selected State = 
VAR __allLabel = "The U.S."
VAR __maxCount = 5
VAR __maxLabel = "multiple states"
VAR __totalCount = CALCULATE(DISTINCTCOUNT('Table'[State]),ALL('Table'))
VAR __selectedCount = DISTINCTCOUNT('Table'[State])
RETURN
	IF(		
		__selectedCount = 1,
		VALUES('Table'[State]), 
		IF (
			__selectedCount = __totalCount, 
			__allLabel,
			IF (
				__selectedCount > __maxCount,
				__maxLabel,
				CONCATENATEX(TOPN(__selectedCount-1,VALUES('Table'[State])),'Table'[State],", ") & " and " & LASTNONBLANK(VALUES('Table'[State]),true)
			)
		)
	)

 

Attachment