Forum Discussion
Filters Selected as Text with multiple selections
The report consumer has asked that whatever filters are selected in the filter pop out, are displayed in text at the top of the page. I wrote the measure out for this and it works great except when multiple months are selected. I tried multiple ways, but many options threw errors. Below is the code that I have right that is working for everything but the multiple months. The user report consumer would like it setup with: "MonthName Year - MonthName Year". I tried variations of Min and Max to no avail. The particular page this is one has a page level filter of Current Year only (Year Offset of 0), but with Min and Max, the output would show as "April 2018 - October 2021".
Filter Text =
IF(
ISFILTERED('Date'[End of Week]),
CONCATENATE(MIN('Date'[Date]),
CONCATENATE(" - ", MAX('Date'[Date]))),
IF(
ISFILTERED('Date'[Month Name]),
CONCATENATE("Month: ",
CONCATENATE(SELECTEDVALUE('Date'[Month Name]),
CONCATENATE(" ", MAX('Date'[Year])))),
IF(
ISFILTERED('Date'[Day]),
CONCATENATE(MIN('Date'[Date]),
CONCATENATE(": ", MAX('Date'[Date]))),
"YEAR-TO-DATE"
)))I was able to figure it out. Below is the DAX Measure that worked. I teamed up ISFILTERED and HASONEVALUE in the first step, and then if it doesn't pass that step as TRUE, then it moves on to an AND statement which will allow for the multiple. Thanks for all your help
Filter Text = IF( ISFILTERED('Date'[End of Week]), CONCATENATE(MIN('Date'[Date]), CONCATENATE(" - ", MAX('Date'[Date]))), IF( ISFILTERED('Date'[Month Name]) && HASONEVALUE('Date'[Month Name]), CONCATENATE("Month: ", SELECTEDVALUE('Date'[Month Year])), IF( AND(ISFILTERED('Date'[Month Name]), ISFILTERED('Date'[Month Name])), CONCATENATE("Month: ", CONCATENATE(MIN('Date'[Month Year]), CONCATENATE(" - ", MAX('Date'[Month Year])))), IF( ISFILTERED('Date'[Day]), CONCATENATE(MIN('Date'[Date]), CONCATENATE(": ", MAX('Date'[Date]))), "YEAR-TO-DATE" ))))
6 Replies
- AllisonKennedyCommunity Champion
dbrandone Can you share screenshots or more specifics on all the filters you have on the page?
I find CONCATENATEX to be a handy function when displaying filter selections at top of page - it lets you show all the values that are selected when multiple values have been selected.
Not sure what you mean by Date range would show as "April 2018 - October 2021" ??? What do you expect or want it to show instead? If you have a filter on the Date table, the MIN and MAX should return the values within all the filter ranges... Do you have a [Month Year] column?
You may need to try something like:
Month Range Selected =
VAR _minDate = MIN(Date[Date])VAR _maxDate = MAX(Date[Date])
VAR _minMMYY = MINX(FILTER(Date, Date[Date] = _minDate), Date[Month Year])
VAR _maxMMYY = MAXX(FILTER(Date, Date[Date] = _maxDate), Date[Month Year])
RETURN
_minDate & " - " & _maxDate
- dbrandoneHelper IV
I was able to figure it out. Below is the DAX Measure that worked. I teamed up ISFILTERED and HASONEVALUE in the first step, and then if it doesn't pass that step as TRUE, then it moves on to an AND statement which will allow for the multiple. Thanks for all your help
Filter Text = IF( ISFILTERED('Date'[End of Week]), CONCATENATE(MIN('Date'[Date]), CONCATENATE(" - ", MAX('Date'[Date]))), IF( ISFILTERED('Date'[Month Name]) && HASONEVALUE('Date'[Month Name]), CONCATENATE("Month: ", SELECTEDVALUE('Date'[Month Year])), IF( AND(ISFILTERED('Date'[Month Name]), ISFILTERED('Date'[Month Name])), CONCATENATE("Month: ", CONCATENATE(MIN('Date'[Month Year]), CONCATENATE(" - ", MAX('Date'[Month Year])))), IF( ISFILTERED('Date'[Day]), CONCATENATE(MIN('Date'[Date]), CONCATENATE(": ", MAX('Date'[Date]))), "YEAR-TO-DATE" ))))- AllisonKennedyCommunity Champion
dbrandone Well done! You are spot on with the && HASONEVALUE but shouldn't need the AND() function:
Filter Text = IF( ISFILTERED('Date'[End of Week]), CONCATENATE(MIN('Date'[Date]), CONCATENATE(" - ", MAX('Date'[Date]))), IF( ISFILTERED('Date'[Month Name]) && HASONEVALUE('Date'[Month Name]), CONCATENATE("Month: ", SELECTEDVALUE('Date'[Month Year])), IF( ISFILTERED('Date'[Month Name]), CONCATENATE("Month: ", CONCATENATE(MIN('Date'[Month Year]), CONCATENATE(" - ", MAX('Date'[Month Year])))), IF( ISFILTERED('Date'[Day]), CONCATENATE(MIN('Date'[Date]), CONCATENATE(": ", MAX('Date'[Date]))), "YEAR-TO-DATE" ))))
- dbrandoneHelper IV
What I meant with "April 2018 - October 2021" is that the page has "year offset" filter of 0 so I do not know why the text field on the page would show April 2018 when no filters are present since the whole page cannot go prior to Jan 1, 2021.
I will try your solution and see if it helps my situation. Thanks for the reply
- dbrandoneHelper IV
Below is the picture of the filters I currently have. Multi select is enabled on the Month filter.