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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Search for multiple selections from filter

I am trying to count the number of issues in a table that include or do not include tags. I have created a formula that will count the number of issues that include or exclude a specific tag, but I cannot get it to work for multiple selections from the tag filter. The filter has single tags, but it searches the a column that is a concatenation of all tags on the issue. There is also a filter that decides if the tag should be included or excluded.

 

Total Tickets = if(max('Action'[Tag Action])="include",CALCULATE(count(Issues[Issue ID]),filter(Issues,SEARCH(SELECTEDVALUE('Banned Tags'[Tag]),Issues[Tags (concatenated)],,BLANK()))),if(max('Action'[Tag Action])="exclude",CALCULATE(count(Issues[Issue ID]),filter(Issues,NOT(SEARCH(SELECTEDVALUE('Banned Tags'[Tag]),Issues[Tags (concatenated)],,BLANK()))))))

5 REPLIES 5
v-shex-msft
Community Support
Community Support

HI @Anonymous,

 

I'd like to suggest you use SWITCH function to get logical variable to use it in your formula.

Sample measure:

Total Tickets =
VAR logicAction =
    SWITCH (
        MAX ( 'Action'[Tag Action] ),
        "include", TRUE (),
        "exclude", FALSE (),
        FALSE ()
    )
RETURN
    CALCULATE (
        COUNT ( Issues[Issue ID] ),
        FILTER (
            Issues,
            SEARCH (
                SELECTEDVALUE ( 'Banned Tags'[Tag] ),
                Issues[Tags (concatenated)],
                ,
                BLANK ()
            )
                = logicAction
        )
    )

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

Thank you Xiaoxin Sheng for your suggestion, but I received the following error "calculation error in measure: DAX comparison operations do not support comparing values of type Integer with values of type True/False."

 

Additionally, I believe switch is just assisting with the ability to include or exclude the tag in the count. The if formula I used is accomplishing the ability to toggle between those two actions. The problem is when multiple tags are selected from the filter, the calcuation will not check for the two different tags.

Hi @Anonymous,

 

I modify formula to work through convert search function result as boolean:

Total Tickets =
VAR logicAction =
    SWITCH (
        MAX ( 'Action'[Tag Action] ),
        "include", TRUE (),
        "exclude", FALSE (),
        FALSE ()
    )
RETURN
    CALCULATE (
        COUNT ( Issues[Issue ID] ),
        FILTER (
            Issues,
            (
                SEARCH (
                    SELECTEDVALUE ( 'Banned Tags'[Tag] ),
                    Issues[Tags (concatenated)],
                    ,
                    BLANK ()
                )
                    >= 1
            )
                = logicAction
        )
    )

>>The problem is when multiple tags are selected from the filter, the calcuation will not check for the two different tags.

Yes, SWITCH function not works for summary contents, so it not works on multiple selections. I don't think your tables contains rows who can include and exclude specific characters at same time

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

The updated formula you provided works when a single selection is made, but not when multiple selections are made in the tag filter. Are you saying there is no way to create a formula that will check for multiple tags?

Hi @Anonymous,

 

I think it is hard to achieve search operation between list and text value, can you please provide some of sample data to test?

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors