Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
dbrandone
Helper IV
Helper IV

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.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

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

@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.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.