cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dbrandone
Helper III
Helper III

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"
                )))
1 ACCEPTED SOLUTION

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"
                    ))))

View solution in original post

6 REPLIES 6
AllisonKennedy
Super User
Super User

@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

 


Please @mention me in your reply if you want a response.

Check out my Tokyo 2020 report with live stats - KUDOS much appreciated

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

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"
                    ))))

View solution in original post

@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"
                    ))))

Please @mention me in your reply if you want a response.

Check out my Tokyo 2020 report with live stats - KUDOS much appreciated

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

@AllisonKennedy 

 

I guess the crux of the issue would the correct logical expression within the IF statement for the month filter that will correctly realize when multiple months are selected but not all months selected as that would be YTD. 

 

Right now, I have the ISFILTERED for one month selected and it works. I have the if true statement working, but what logical statement will push correctly to see more than one month is chosen and therefore MIN and MAX months are shown. I guess in terms of Psuedo code it would look like:

 

IF(

    MULTIPLE(ISFILTERED('DATE'[MONTH])),

    CONCATENATE(MIN('DATE'[MONTH YEAR]),

         CONCATENATE(" - ", MAX('Date'[MONTH YEAR]))),

    "YEAR-TO-DATE"
)

@AllisonKennedy 

 

Below is the picture of the filters I currently have. Multi select is enabled on the Month filter.

 

dbrandone_0-1634308857817.png

 

@AllisonKennedy 

 

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

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.