Forum Discussion

barragan82's avatar
barragan82
Icon for Helper II rankHelper II
1 year ago
Solved

How to generate text based on selected values from a slicer.

Hi,   I'm trying to auto generate text if I select specific values in a slicer. In the example below, I am trying to auto generate "Group Project" if C/A/G and C/A/G/I are selected. I used this DAX...
  • v-venuppu's avatar
    11 months ago

    Hi barragan82 ,

    The issue with your measure is that CONCATENATEX on the column returns all values (not just the slicer selection) and the text comparison is very order-sensitive. If you click the slicer in a different order, the concatenated string doesn’t match your C/A/G, C/A/G/I test.

    The other way is to check directly whether those values are selected, regardless of order:
    Group Project Text =
    VAR sel = VALUES('Master Core AY24-25'[WC])
    VAR hasCAG = "C/A/G" IN sel
    VAR hasCAGI = "C/A/G/I" IN sel
    RETURN
    IF( hasCAG && hasCAGI, "Group Project", "Blank" )
    This returns "Group Project" if both C/A/G and C/A/G/I are selected in the slicer, otherwise "Blank".
    It won’t matter in which order the user selects them.

    Thank you.

  • barragan82's avatar
    barragan82
    10 months ago

    Hi v-venuppu ,

     

    I aplogize for not replying sooner, I have not been in the forum for a while. I was able to find a separate solution with the following DAX formula. Thank you for checking in!

     

    Group Test 3 = IF(
        CALCULATE(COUNTROWS(FILTER('Master Core AY24-25','Master Core AY24-25'[WC]IN{"C/A/G/","C/A/G/I"})))>0,"Group Project")